php - Laravel 5.2 flash messages not working -
i using use flash; display flash messages not showing
protected function store(request $request) { $this->validate($request, [ 'service_name' => 'required' ]); $service = new service(); $service->service_name = $request->input('service_name'); $service->business_id = auth::user()->user_id; $service->save(); flash::message('service added'); return redirect('/business/editservices'); }
view code
@if (session::has('flash_notification.message')) <div class="alert alert-{{ session::get('flash_notification.level') }}"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> {{ session::get('flash_notification.message') }} </div> @endif
what might problem?please help
if have request object use flash:
protected function store(request $request) { $this->validate($request, [ 'service_name' => 'required' ]); $service = new service(); $service->service_name = $request->input('service_name'); $service->business_id = auth::user()->user_id; $service->save(); $request->session()->flash('message', 'service added'); return redirect('/business/editservices'); }
or esiaer using redirect:
return redirect('/business/editservices')->with('message', 'service added');
and then:
session::has('message');
Comments
Post a Comment