php - Laravel Message Bag Error -
am working on form validations newsletter project on, news letter form appears on every page appear on longin , registration page decided make use of laravel message bags store news letter errors keeps giving me undefined property error on actual page check , output echo errors, don't know if doing wrong here details though!
the error:
undefined property: illuminate\support\messagebag::$newsletter
my code in controller:
return redirect::back()->withinput()->witherrors($inputs, "newsletter");
my code in view:
@if($errors->newsletter->any()) <p> {{$errors->newsletter->any()}} </p>
the redirectresponse
class function witherrors()
doesn't have second parameter..
the function vendor\laravel\framework\src\illuminate\http\redirectresponse.php -> witherrors()
:
/** * flash container of errors session. * * @param \illuminate\support\contracts\messageproviderinterface|array $provider * @return \illuminate\http\redirectresponse */ public function witherrors($provider) { if ($provider instanceof messageproviderinterface) { $this->with('errors', $provider->getmessagebag()); } else { $this->with('errors', new messagebag((array) $provider)); } return $this; }
so, if want use messagebag
should work (didn't test it):
$your_message_bag = new illuminate\support\messagebag; $your_message_bag->add('foo', 'bar'); return redirect::back()->withinput()->witherrors($your_message_bag->all());
Comments
Post a Comment