Here is the Controller function:
public function index() {
//get wizardries
$wizardry = Wizardry::where('lang', Lang::getLocale())
->where('active', 1)
->inRandomOrder()
->limit(1)
->first();
//get featured projects with category and wizardries
$projects = Project::where('lang', Lang::getLocale())
->where('active', 1)
->where('featured_project', 1)
->inRandomOrder()
->limit(5)
->with('category')
->with('media')
->with('wizardries')->get();
//get clients
$clients = Client::orderBy('order')->where('active',1)->limit(5)->inRandomOrder()->get();
$this->meta['description'] = trans('meta.home.description');
$this->meta['title'] = trans('meta.home.title') . ' - ' . env('APP_NAME');
View::share('wizardry', $wizardry);
View::share('projects', $projects);
View::share('clients', $clients);
view()->share('body_class', 'home');
View::share('meta', $this->meta);
return view("home");
}
In the view, a partial for the head section the code usage is as follows:
body class="{{ $body_class or '' }}"
The thing is, the issue seems to be with the {{ }} since it replaced with the following php code and the values are echoing correctly:
body class=" php echo isset($body_class) ? $body_class: '';"
(i removed the open and close markup and php tags)
So it doesn't seem to be an issue with the variable assignment but with the echoing.
Notice that all the other assignments, namely the ones resulting from Eloquent queries are working fine. The $meta array also echoes the value 1.
I managed to work around it using regular php code but it bothers me not understanding why something doesn't work.