I am using laravel, I have a variable in my dashboard controller (which extends the base controller) defined as follows:
Dashboard Controller:
public function dashboardData(){
$toReturn = array();
$toReturn['siteTitle'] = $this->data['panelInit']->settingsArray['siteTitle'];
//------other things-----------//
$toReturn['stats'] = array();
//------some other things-----------//
$toReturn['stats']['recieved'] = messagesList::where('userId',$this->data['users']->id)->where('messageStatus',1)->count();
This variable is shown in my main(index/default/home/whatever you call it) html template by using the {{}} syntax as follows:
HTML Template
<div class="counter">
<div class="informational">{{dashboardData.stats.recieved}}</div>
</div>
and it completely shows the result I expect.... but I want to show this same data in a layout blade that I am using... I am using the same html structure in the layout.blade (directory:/app/views) with {{dashboardData.stats.recieved}} but I am getting "Undefined Constant" and "undefined Variable" errors...
following is a glimpse of my routes.php:-
routes.php
Route::group(array('prefix'=>'/','before'=>'auth.Ui|auth.token|api.csrf'),function(){
Route::get('/','DashboardController@index');
Route::get('/dashboard','DashboardController@dashboardData');
Route::get('/dashboard/baseUser','DashboardController@baseUser');
//-------------some things-------------//
Route::post('/dashaboard','DashboardController@dashaboardData');
I am quite new on laravel, I have stumbled upon the "view::share" and "view:make" thing but didn't quite get it how to do it perfectly & securely without a single error... I also have a library setup in the "/app/libraries/initiation.php" that reflects some data to layout.blade....How do I show the data {{dashboardData.stats.recieved}} in the layout.blade without the errors "Undefined Constant" and "undefined Variable"...??? and also what would be the most correct, practical and most importantly secure way of doing so...???