<?php namespace App\Http\Controllers;
        header("Access-Control-Allow-Origin: *");

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

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

		    function __construct() {    
				$this->table       = "apps";        
				$this->permalink   = "laporan_umkm";    
				$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){
                    $result['usaha'] = DB::table('umkm_usaha')->count();
                    $result['pemilik_usaha_lokal'] = DB::table('umkm_pemilik')
                                                            ->join('warga_bjb','umkm_pemilik.warga_bjb_id','warga_bjb.id')
                                                            ->where('warga_bjb.nama_kab','6372')
                                                            ->count();
                    $result['pemilik_usaha_luar'] = DB::table('umkm_pemilik')
                                                            ->join('warga_bjb','umkm_pemilik.warga_bjb_id','warga_bjb.id')
                                                            ->where('warga_bjb.nama_kab','<>','6372')
                                                            ->count();
                }
		    }

		}