I am working on a custom Laravel Project.
I am getting following error:
Undefined variable: count_pandding (View: /domains/web4/html/manager/app/views/admin/home.blade.php)
but strange thing is this error does not show in localhost and works perfectly only in life server.
I have tried passing variables in 2 ways:
public function home()
{
$count_pandding = \Postjob::where('approve',0)->get()->count();
$count_disapprove = \Postjob::where('approve',2)->get()->count();
$count_approve = \Postjob::where('approve',1)->get()->count();
$count_expire = \Postjob::where('approve',3)->get()->count();
return View::make('admin.home', compact('count_pandding','count_disapprove','count_approve','count_expire'));
}
and 2nd way
public function home()
{
$data['count_pandding'] = \Postjob::where('approve',0)->get()->count();
$data['count_disapprove'] = \Postjob::where('approve',2)->get()->count();
$data['count_approve'] = \Postjob::where('approve',1)->get()->count();
$data['count_expire'] = \Postjob::where('approve',3)->get()->count();
return View::make('admin.home',$data);
}
None of it works in Life Server! But works perfectly in Localhost.
Please review Larvel Response
The second parameter of make is an array with key value bindings. I find it strange that this is working on your local machine.
Try
return View::make('admin.home', [
'count_pandding' => $count_pandding,
...
]);
Or
return View::make('admin.home')->withCountPannding($count_pannding);
//this becomes $countPannding in your view
Update:
return View::make('admin.home')->with($keyValueArray);
//should also translate into $key inside the view.