lundi 3 octobre 2016

ErrorException in helpers.php line 531: htmlentities() expects parameter 1 to be string, array given

this page works perfectly with few of rows in my database. but when i insert a lot of rows to database i get this error. thanks for any help and sorry for my bad english :). here is the code:

Stack Trace

2/2

ErrorException in helpers.php line 531:
    htmlentities() expects parameter 1 to be string, array given (View: /Volumes/data/Workspace/laravel/software_database_ihhp/resources/views/pages/filter.blade.php)
    in helpers.php line 531
    at CompilerEngine->handleViewException(object(ErrorException), '1') in PhpEngine.php line 44
    at PhpEngine->evaluatePath('/Volumes/data/Workspace/laravel/software_database_ihhp/storage/framework/views/1afac4780cd02b762a2c4afc0c75fd690537a799.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'kblicodes' => object(Collection), 'getkbli' => '16221', 'imports' => object(LengthAwarePaginator), 'neto_import' => '0', 'value_import' => '0', 'import_tahun_all' => object(Collection), 'import_negara_all' => object(Collection), 'exports' => object(LengthAwarePaginator), 'export_tahun_all' => object(Collection), 'export_negara_all' => object(Collection), 'neto_export' => '384753', 'value_export' => '815644', 'tahun_array' => array('2000', '2001', '2002', '2003', '2005', '2006', '2007'), 'negaraArray' => array('AFGHANISTAN' => 'AF', 'UNITED ARAB EMIRATES' => 'AE'), 'pelabuhanArray' => array('BELAWAN' => 'IDBLW', 'MUARA SABAK' => 'IDMSA', 'MUSI RIVER/BOOM BARU' => 'IDMRI', 'SAMARINDA' => 'IDSRD', 'SM' => array(' BADARUDDIN (U)' => 'IDPLM'), 'TANJUNG EMAS' => 'IDTES', 'TANJUNG PERAK' => 'IDTPE', 'TANJUNG PRIOK' => 'IDTPP'), 'gettahun' => null, 'getnegara' => null, 'getpelabuhan' => null)) in CompilerEngine.php line 59
    at CompilerEngine->get('/Volumes/data/Workspace/laravel/software_database_ihhp/resources/views/pages/filter.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'kblicodes' => object(Collection), 'getkbli' => '16221', 'imports' => object(LengthAwarePaginator), 'neto_import' => '0', 'value_import' => '0', 'import_tahun_all' => object(Collection), 'import_negara_all' => object(Collection), 'exports' => object(LengthAwarePaginator), 'export_tahun_all' => object(Collection), 'export_negara_all' => object(Collection), 'neto_export' => '384753', 'value_export' => '815644', 'tahun_array' => array('2000', '2001', '2002', '2003', '2005', '2006', '2007'), 'negaraArray' => array('AFGHANISTAN' => 'AF', 'UNITED ARAB EMIRATES' => 'AE'), 'pelabuhanArray' => array('BELAWAN' => 'IDBLW', 'MUARA SABAK' => 'IDMSA', 'MUSI RIVER/BOOM BARU' => 'IDMRI', 'SAMARINDA' => 'IDSRD', 'SM' => array(' BADARUDDIN (U)' => 'IDPLM'), 'TANJUNG EMAS' => 'IDTES', 'TANJUNG PERAK' => 'IDTPE', 'TANJUNG PRIOK' => 'IDTPP'), 'gettahun' => null, 'getnegara' => null, 'getpelabuhan' => null)) in View.php line 149
    at View->getContents() in View.php line 120
    at View->renderContents() in View.php line 85
    at View->render() in Response.php line 53
    at Response->setContent(object(View)) in Response.php line 201
    at Response->__construct(object(View)) in Router.php line 1085
    at Router->prepareResponse(object(Request), object(View)) in ControllerDispatcher.php line 95
    at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
    at Pipeline->Illuminate\Routing\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
    at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
    at ControllerDispatcher->callWithinStack(object(PagesController), object(Route), object(Request), 'filterKomoditi') in ControllerDispatcher.php line 54
    at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\PagesController', 'filterKomoditi') in Route.php line 174
    at Route->runController(object(Request)) in Route.php line 140
    at Route->run(object(Request)) in Router.php line 724
    at Router->Illuminate\Routing\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
    at VerifyCsrfToken->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
    at ShareErrorsFromSession->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
    at StartSession->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
    at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
    at EncryptCookies->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
    at Pipeline->Illuminate\Routing\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
    at Pipeline->then(object(Closure)) in Router.php line 726
    at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
    at Router->dispatchToRoute(object(Request)) in Router.php line 675
    at Router->dispatch(object(Request)) in Kernel.php line 246
    at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
    at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
    at CheckForMaintenanceMode->handle(object(Request), object(Closure))
    at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
    at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
    at Pipeline->Illuminate\Routing\{closure}(object(Request))
    at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
    at Pipeline->then(object(Closure)) in Kernel.php line 132
    at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
    at Kernel->handle(object(Request)) in index.php line 54

1/2

ErrorException in helpers.php line 531:
htmlentities() expects parameter 1 to be string, array given
in helpers.php line 531
at HandleExceptions->handleError('2', 'htmlentities() expects parameter 1 to be string, array given', '/Volumes/data/Workspace/laravel/software_database_ihhp/vendor/laravel/framework/src/Illuminate/Support/helpers.php', '531', array('value' => array(' BADARUDDIN (U)' => 'IDPLM')))
at htmlentities(array(' BADARUDDIN (U)' => 'IDPLM'), '3', 'UTF-8', false) in helpers.php line 531
at e(array(' BADARUDDIN (U)' => 'IDPLM')) in 1afac4780cd02b762a2c4afc0c75fd690537a799.php line 101
at include('/Volumes/data/Workspace/laravel/software_database_ihhp/storage/framework/views/1afac4780cd02b762a2c4afc0c75fd690537a799.php') in PhpEngine.php line 42
at PhpEngine->evaluatePath('/Volumes/data/Workspace/laravel/software_database_ihhp/storage/framework/views/1afac4780cd02b762a2c4afc0c75fd690537a799.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'kblicodes' => object(Collection), 'getkbli' => '16221', 'imports' => object(LengthAwarePaginator), 'neto_import' => '0', 'value_import' => '0', 'import_tahun_all' => object(Collection), 'import_negara_all' => object(Collection), 'exports' => object(LengthAwarePaginator), 'export_tahun_all' => object(Collection), 'export_negara_all' => object(Collection), 'neto_export' => '384753', 'value_export' => '815644', 'tahun_array' => array('2000', '2001', '2002', '2003', '2005', '2006', '2007'), 'negaraArray' => array('AFGHANISTAN' => 'AF', 'UNITED ARAB EMIRATES' => 'AE'), 'pelabuhanArray' => array('BELAWAN' => 'IDBLW', 'MUARA SABAK' => 'IDMSA', 'MUSI RIVER/BOOM BARU' => 'IDMRI', 'SAMARINDA' => 'IDSRD', 'SM' => array(' BADARUDDIN (U)' => 'IDPLM'), 'TANJUNG EMAS' => 'IDTES', 'TANJUNG PERAK' => 'IDTPE', 'TANJUNG PRIOK' => 'IDTPP'), 'gettahun' => null, 'getnegara' => null, 'getpelabuhan' => null)) in CompilerEngine.php line 59
at CompilerEngine->get('/Volumes/data/Workspace/laravel/software_database_ihhp/resources/views/pages/filter.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'kblicodes' => object(Collection), 'getkbli' => '16221', 'imports' => object(LengthAwarePaginator), 'neto_import' => '0', 'value_import' => '0', 'import_tahun_all' => object(Collection), 'import_negara_all' => object(Collection), 'exports' => object(LengthAwarePaginator), 'export_tahun_all' => object(Collection), 'export_negara_all' => object(Collection), 'neto_export' => '384753', 'value_export' => '815644', 'tahun_array' => array('2000', '2001', '2002', '2003', '2005', '2006', '2007'), 'negaraArray' => array('AFGHANISTAN' => 'AF', 'UNITED ARAB EMIRATES' => 'AE'), 'pelabuhanArray' => array('BELAWAN' => 'IDBLW', 'MUARA SABAK' => 'IDMSA', 'MUSI RIVER/BOOM BARU' => 'IDMRI', 'SAMARINDA' => 'IDSRD', 'SM' => array(' BADARUDDIN (U)' => 'IDPLM'), 'TANJUNG EMAS' => 'IDTES', 'TANJUNG PERAK' => 'IDTPE', 'TANJUNG PRIOK' => 'IDTPP'), 'gettahun' => null, 'getnegara' => null, 'getpelabuhan' => null)) in View.php line 149
at View->getContents() in View.php line 120
at View->renderContents() in View.php line 85
at View->render() in Response.php line 53
at Response->setContent(object(View)) in Response.php line 201
at Response->__construct(object(View)) in Router.php line 1085
at Router->prepareResponse(object(Request), object(View)) in ControllerDispatcher.php line 95
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack(object(PagesController), object(Route), object(Request), 'filterKomoditi') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\PagesController', 'filterKomoditi') in Route.php line 174
at Route->runController(object(Request)) in Route.php line 140
at Route->run(object(Request)) in Router.php line 724
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 726
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 54

PagesController

public function filterKomoditi(Request $request){
        $kblicodes = Kblicode::groupBy('kblicode')->lists('kblicode', 'kblicode');

        // mengambil parameter
        $getkbli = $request->get('kbli');
        $gettahun = $request->get('tahun');
        $getnegara = $request->get('negara');
        $getpelabuhan = $request->get('pelabuhan');

        if($getkbli!=null){
            $hscode = Kblicode::where('kblicode', $getkbli)->get();
        }

        // fungsi select import where multiple hscode
        $condition = array();
            foreach ($hscode as $hs) {
                array_push($condition, $hs->hscode);
            }

        // fungsi filter
        if($gettahun != null && $getnegara != null && $getpelabuhan !=null){
            $imports = Import::whereIn('hscode', $condition)->whereIn('tahun', $gettahun)->whereIn('kode_negara', $getnegara)->whereIn('kode_pelabuhan', $getpelabuhan);
            $exports = Export::whereIn('hscode', $condition)->whereIn('tahun', $gettahun)->whereIn('kode_negara', $getnegara)->whereIn('kode_pelabuhan', $getpelabuhan);
        }elseif($gettahun != null && $getnegara == null && $getpelabuhan ==null){
            $imports = Import::whereIn('hscode', $condition)->whereIn('tahun', $gettahun);
            $exports = Export::whereIn('hscode', $condition)->whereIn('tahun', $gettahun);
        }elseif($gettahun == null && $getnegara != null && $getpelabuhan ==null){
            $imports = Import::whereIn('hscode', $condition)->whereIn('kode_negara', $getnegara);
            $exports = Export::whereIn('hscode', $condition)->whereIn('kode_negara', $getnegara);    
        }elseif($gettahun == null && $getnegara == null && $getpelabuhan !=null){
            $imports = Import::whereIn('hscode', $condition)->whereIn('kode_pelabuhan', $getpelabuhan);
            $exports = Export::whereIn('hscode', $condition)->whereIn('kode_pelabuhan', $getpelabuhan);
        }elseif($gettahun == null && $getnegara == null && $getpelabuhan ==null){
            $imports = Import::whereIn('hscode', $condition);
            $exports = Export::whereIn('hscode', $condition);    
        }elseif($gettahun != null && $getnegara != null && $getpelabuhan ==null){
            $imports = Import::whereIn('hscode', $condition)->whereIn('tahun', $gettahun)->whereIn('kode_negara', $getnegara);
            $exports = Export::whereIn('hscode', $condition)->whereIn('tahun', $gettahun)->whereIn('kode_negara', $getnegara);    
        }elseif($gettahun != null && $getnegara == null && $getpelabuhan !=null){
            $imports = Import::whereIn('hscode', $condition)->whereIn('tahun', $gettahun)->whereIn('kode_pelabuhan', $getpelabuhan);
            $exports = Export::whereIn('hscode', $condition)->whereIn('tahun', $gettahun)->whereIn('kode_pelabuhan', $getpelabuhan);    
        }elseif($gettahun == null && $getnegara != null && $getpelabuhan !=null){
            $imports = Import::whereIn('hscode', $condition)->whereIn('kode_negara', $getnegara)->whereIn('kode_pelabuhan', $getpelabuhan);
            $exports = Export::whereIn('hscode', $condition)->whereIn('kode_negara', $getnegara)->whereIn('kode_pelabuhan', $getpelabuhan);    
        }

        // fungsi select tahun negara, dan pelabuhan dari data Import
        $import_tahun_all = Import::whereIn('hscode', $condition)->groupBy('tahun')->get();
        $import_negara_all = Import::whereIn('hscode', $condition)->groupBy('nama_negara')->get();
        $import_pelabuhan_all = Import::whereIn('hscode', $condition)->groupBy('nama_pelabuhan')->get();

        // fungsi select tahun dan negara dari data export
        $export_tahun_all = Export::whereIn('hscode', $condition)->groupBy('tahun')->get();
        $export_negara_all = Export::whereIn('hscode', $condition)->groupBy('nama_negara')->get();
        $export_pelabuhan_all = Export::whereIn('hscode', $condition)->groupBy('nama_pelabuhan')->get();

        //tahun array
        $tahun_array = array();            
            foreach ($import_tahun_all as $import_tahun){
                if(!in_array($import_tahun->tahun, $tahun_array)){
                    array_push($tahun_array, $import_tahun->tahun);
                }
            }
            foreach ($export_tahun_all as $export_tahun){
                if(!in_array($export_tahun->tahun, $tahun_array)){
                    array_push($tahun_array, $export_tahun->tahun);
                }
            }
        sort($tahun_array);

        // negara array with key => value. 
          $negaraArray = [];
          foreach ($import_negara_all as $import_negara){
              if(!array_key_exists($import_negara->nama_negara, $negaraArray)){
                  $negaraArray = array_add($negaraArray, $import_negara->nama_negara, $import_negara->kode_negara);
              }
          }
          foreach ($export_negara_all as $export_negara){
              if(!array_key_exists($export_negara->nama_negara, $negaraArray)){
                  $negaraArray = array_add($negaraArray, $export_negara->nama_negara, $export_negara->kode_negara);
              }
          }
        ksort($negaraArray);

        // pelabuhanArray with key => value
        $pelabuhanArray = [];
        foreach ($import_pelabuhan_all as $import_pelabuhan){
              if(!array_key_exists($import_pelabuhan->nama_pelabuhan, $pelabuhanArray)){
                  $pelabuhanArray = array_add($pelabuhanArray, $import_pelabuhan->nama_pelabuhan, $import_pelabuhan->kode_pelabuhan);
              }
          }
          foreach ($export_pelabuhan_all as $export_pelabuhan){
              if(!array_key_exists($export_pelabuhan->nama_pelabuhan, $pelabuhanArray)){
                  $pelabuhanArray = array_add($pelabuhanArray, $export_pelabuhan->nama_pelabuhan, $export_pelabuhan->kode_pelabuhan);
              }
          }
          ksort($pelabuhanArray);


        // paginate
        $imports = $imports->paginate();
        $exports = $exports->paginate();

        // fungsi sum berat bersih dan nilai
        $neto_import = $imports->sum('berat_bersih');
        $value_import = $imports->sum('nilai');
        $neto_export = $exports->sum('berat_bersih');
        $value_export = $exports->sum('nilai');

        return view('pages.filter', compact('kblicodes', 'getkbli', 'imports', 'neto_import', 'value_import', 'import_tahun_all', 'import_negara_all', 'exports', 'export_tahun_all', 'export_negara_all', 'neto_export', 'value_export', 'tahun_array', 'negaraArray', 'pelabuhanArray', 'gettahun', 'getnegara','getpelabuhan')); 
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire