<?php namespace App\Http\Controllers;

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

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

		    function __construct() {    
				$this->table       = "wablast";        
				$this->permalink   = "get_blast";    
				$this->method_type = "get";    
		    }
		

		    public function hook_before(&$postdata) {
		        //This method will be execute before run the main process
                $postdata['baru'] = DB::table('wablast_target')
                                    ->join('wablast','wablast_target.id_wablast','wablast.id')
                                    // ->leftJoin('waconv','waconv.id','wablast_target.id_waconv')
                                    ->where('wablast_target.status','baru')
                                    ->get();
                if(sizeof($postdata['baru'])==0){
                    $resp = response()->json(['api_status'=>0,'api_message'=>'tidak ada data.']);
                    $resp->send();
                    exit();
                }
                
		    }

		    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){
		            foreach($result['data'] as $data){
		                $data->baru = $postdata['baru'];
		                foreach($postdata['baru'] as $baru){
		                   // DB::table('wablast_target')->where('')update([])
		                }
		            }
		        }
                
		    }

		}