Support the ongoing development of Laravel.io →
Views Blade Testing

I would like to call my header CSS file in every pages, so I created a function to calling the header which the code as below and this code are in BaseController.php

public function __construct()
{
	Asset::container('header')
		->add('style','css/style.css');

	parent::__construct();
}

public function __call($method, $parameters)
{
    return Response::error('404');
}

After I done the function I'm call the function at layout.blade.php with the following code.

{{ Asset::container('header')->styles() }}

But I failed to view my pages with Class 'Asset' not found. Which part I missed or my source are not correct?

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.