<?php namespace App\Http\Controllers;

		use Session;
		use Request;
		use DB;
		use CRUDBooster;

		class ApiGetWabotController extends \crocodicstudio\crudbooster\controllers\ApiController {

		    function __construct() {    
				$this->table       = "cms_users";        
				$this->permalink   = "get_wabot";    
				$this->method_type = "post";    
		    }
		

		    public function hook_before(&$postdata) {
		        //This method will be execute before run the main process

		    }

		    public function hook_query(&$query) {
		        //This method is to customize the sql query

		    }

		    public function hook_after($postdata,&$result) {
		        //This method will be execute after run the main process
                if($result['api_status']==1){
                    $wabot=DB::table('wabot')
                            ->where('grup_id', $postdata['grup_id'])
                            ->get();
                            
                    foreach($wabot as $bot){
		               $pecah = explode(",",$bot->contains);
		               if(sizeof($pecah)>0){
		               $contains = Array();
    		               foreach($pecah as $p){
    		                   array_push($contains,$p);
    		               }
    		               $bot->contains = $contains;
		               }
		               $bot->exact = Array($bot->exact);
		           }
		           
		           $result['bot'] = $wabot;
                }
		    }

		}