edvinaskrucas / notification

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

Feature/has type #69

Closed npostman closed 7 years ago

npostman commented 8 years ago

A new function to determine if the NotificationBag has a Message of a specific type. I was unable to find a way to do this easy, so I added a function for it.

My usage in Laravel 5: In controller:

$v = Validator::make($request->all(), ['test_field1'=>'required', 'test_field2'=>'required'] );
if($v->fails())
{
    foreach($v->errors()->all() as $m)
        Notification::error( $m );

    return redirect()->back();
}

In Blade template:

<div id="notifications_main" class="notifications">
@if( Notification::has('success') )
<div class="alert-success">
    <ul>
{!! Notification::show('success') !!}
    </ul>
</div>
@endif
</div>
Kyslik commented 7 years ago

Tryouts

If anyone wants to use this and this PR is not merged yet use this:

composer.json

"repositories": [
  {
    "type": "vcs",
    "url": "https://github.com/Kyslik/notification"
  }
],
"require": {
  "edvinaskrucas/notification": "dev-feature-has-type",
},

if you want all-pr that pass tests use this:

"require": {
  "edvinaskrucas/notification": "dev-all-pr",
},