laracasts / Lets-Build-a-Forum-in-Laravel

http://laracasts.com/series/lets-build-a-forum-with-laravel
915 stars 309 forks source link

Flash component doesn't display flash message from a controller #22

Open andreich1980 opened 7 years ago

andreich1980 commented 7 years ago

Let's say I create a thread.

Method ThreadsController@store puts message in a session 'flash', 'Your thread has been published!'

In the main layout we have code

<flash message="{{ session('flash') }}"></flash>

In the Flash component there's a created method that checks if message is presented then calls flash method with the message it has got.

flash(data) {
    this.body = data.message;
     this.level = data.level;
      //...
},

But flash method accepts only one argument and assumes that it's an object with message and level properties.

I think it's time to add level prop to the Flash component and change created method that it would call flash with an object it expects.

I could make a PR if I'm right.