Been at this for ages, can't find a solution. I've searched and none of the posts help, possibly me not getting it as I'm new to Laravel (5.4)
I want to be able to be able to access "$site_settings" from one controller to another. Also "$site_settings" need to be accessible on all controllers and views. I also need to get variable from URL (hence Request in __construct( Request $request ) ) but it doesn't work either.
Would really appreciate any assistance.
Thanks.
See code below:
//BaseController
class BaseController extends Controller {
public function __construct( Request $request )
{
$slug = $request->slug;
$site_settings = \DB::table('sites_settings')->where('slug', $slug)->first();
View::share( 'site_settings', ['slug' => $slug, 'color' => $color] );
}
}
class SettingsController extends BaseController
{
// SettingsController
public function index( )
{
//how do I access $site_settings here and pass it on to the view?
// return view('settings.index');
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire