edvinaskrucas / notification

Notification package for Laravel
MIT License
526 stars 98 forks source link

Don't Understand #47

Closed kevinklika closed 9 years ago

kevinklika commented 9 years ago

I guess I don't entirely understand the usefullness of the default calls (Notification::success(...))...

When would you NOT want to use successInstant instead? I don't understand the use case for the regular notification types... can someone fill me in?

edvinaskrucas commented 9 years ago

Sorry, can`t understand your question... But "successInstant" is used to render message in same request, ant "success" is not.

atwright147 commented 9 years ago

@kevinklika you would use Notification::success() if the action the use requested was successful and Notification::error() if it was not successful. You would then use the others (info and warning) in circumstances in which you decide they are appropriate. Essentially, they simply generate alert-success, alert-danger, alert-info and alert-warning.

Hopefully, this snippet will help to explain:

public function store()
{
    $user = new User;
    $data = Input::all();

    $user->fname    = $data['fname'];
    $user->surname  = $data['surname'];
    $user->email    = $data['email'];
    $user->password = $data['email'];

    if ($user->save()) {
        Notification::success('User successfully updated!');
        return Redirect::route('manage.users.index');
    }
    Notification::error($user->errors()->all());
    return Redirect::route('manage.users.create', array($id));
}
kevinklika commented 9 years ago

The main question was the difference between ::success() and ::successInstant() and when you would want to use each...

edvinaskrucas commented 9 years ago

"::success()" - when message will be rendered after page redirect. "::successInstant()" - when message will be rendered without page redirect

warksit commented 8 years ago

`\Notification::success('Your email address has been verified'); \Notification::successInstant('Your email address has been verified');

return redirect()->route('users.meetings.index');`

Within the view I have @notification

successInstant renders when running tests (phpunit using default laravel setup), success renders when running in browser?!

edvinaskrucas commented 8 years ago

Hey,

success - flash, successInstant - non flash