edvinaskrucas / notification

Notification package for Laravel
MIT License
525 stars 99 forks source link

Array to string conversion error laravel 5.2 #66

Closed matthijs-neijenhuijs closed 8 years ago

matthijs-neijenhuijs commented 8 years ago

This:

{!! Notification::showAll() !!}

gives:

Array to string conversion (View: /Users/matthijs/www/newdutchbridge/resources/views/frontend/basic/contact.blade.php)

edvinaskrucas commented 8 years ago

Can you provide code snippet where you add message to message bag?

matthijs-neijenhuijs commented 8 years ago

This was working in the version 5.0:

public function store() { $result = $this->blog->create(Request::all());

    if(isset($result->id)) {
        \Notification::success('The blog was inserted.');
        return \Redirect::route('admin.blog.index');
    }         

    \Notification::error($result->errors()->all());
    return \Redirect::back()->withInput();  
}

The output of $result->errors()->all():

Array ( [0] => The title must be between 4 and 165 characters. )

edvinaskrucas commented 8 years ago

You need to pass messages as string

matthijs-neijenhuijs commented 8 years ago

So i need to make a foreach loop? It was working in older version. There is no way to send validations errors right away to the notifications?

This is working:

        foreach($result->errors()->all() as $error) {
            \Notification::error($error);
        }

Is it possible to make function likeNotification::errors ?

edvinaskrucas commented 8 years ago

Yes, at the moment you have to