Laravel sharing values from a form in views -
i have project in laravel, want 2 values, resulted after post method form, become global variables in views special prefix.
my code in controller:
public function to_dashboard(userlocationrequest $request) { $my_company_id = $request->my_company_id; $my_branch_id = $request->my_branch_id; view::share('my_company_id', $my_company_id); view::share('my_branch_id', $my_branch_id); return redirect('employee/dashboard'); } after code have errors: 'undefined variable: my_company_id' 'undefined variable: my_branch_id'
how can that, propagate these 2 values in views? or how send these values route.php , become global variables view::share after submitting form?
the way using session in laravel 5.
you put values in session key session::put('key', 'value'); like:
session::put('my_company_id', $my_company_id); session::put('my_branch_id', $my_branch_id); then can fetch values in laravel:
$my_company_id = session::get('my_company_id'); $my_branch_id = session::get('my_branch_id'); i hope cover request.
Comments
Post a Comment