laravel 5 - Passing values from one controller to another -
been @ ages, can't find solution. i've searched , none of posts help, possibly me not getting i'm new laravel (5.4)
i want able able access $site_settings
1 controller another. $site_settings
need accessible on controllers , views. need variable url (hence request
in __construct( request $request )
) doesn't work either.
would appreciate 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 access $site_settings here , pass on view? // return view('settings.index'); } }
---- update session ----
//basecontroller class basecontroller extends controller { public function __construct() { $slug = route::input('slug'); if(session::get('slug') == $slug) { dd(session::get('slug')); } else { $site_settings = \db::table('sites_settings')->where('slug', $slug)->first(); session::put('slug', $site_settings->slug); } }
}
Comments
Post a Comment