-
Notifications
You must be signed in to change notification settings - Fork 49
Alerts
JP Barbosa edited this page Mar 11, 2016
·
3 revisions
nano app/Http/Controllers/ArticlesController.php
...
public function store(ArticleRequest $request)
{
$article = Article::create($request->all());
session()->flash('flash_message', 'Article was stored with success');
...
}
...
public function update(ArticleRequest $request, Article $article)
{
$article->update($request->all());
session()->flash('flash_message', 'Article was updated with success');
...
}
...
public function destroy(Article $article)
{
$deleted = $article->delete();
session()->flash('flash_message', 'Article was removed with success');
...
}
...
nano app/Http/Controllers/AuthorsController.php
...
public function store(AuthorRequest $request)
{
$author = Author::create($request->all());
session()->flash('flash_message', 'Author was stored with success');
...
}
...
public function update(AuthorRequest $request, Author $author)
{
$author->update($request->all());
session()->flash('flash_message', 'Author was updated with success');
...
}
...
public function destroy(Author $author)
{
$deleted = $author->delete();
session()->flash('flash_message', 'Author was removed with success');
...
}
...
nano resources/views/shared/alert.blade.php
<div id='alert-box' class="alert alert-danger"
{!! $errors->any() ? '' : "style='display: none'" !!}
>
<b>Ops...</b>
<ul>
@if ($errors->any())
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
@endif
</ul>
</div>
@if (Session::has('flash_message'))
<div class="alert alert-info">
{{ Session::get('flash_message') }}
</div>
@endif
nano resources/views/articles/index.blade.php; \
nano resources/views/authors/index.blade.php
...
@section('content')
@include('shared.alert')
...
nano resources/views/articles/form.blade.php; \
nano resources/views/authors/form.blade.php
@include('shared.alert')
...
php artisan serve
open http://localhost:8000/articles/create
git add .
git commit -m "Add alerts"
Next step: Welcome Page
- Setup
- Basic CRUD
- Validation
- Views
- Association
- Association Controller
- Association Views
- Basic Template
- Bootstrap
- Bootstrap CRUD
- Alerts
- Welcome Page
- Ajax CRUD
- Send Email
- Send Email Views
- Jobs Queue
- Captcha
- Async External Content
- Cached External Content
- Tests Setup
- Functional Tests
- Acceptance Tests
- Continuous Integration
- Deploy with Heroku
- Deploy with Forge
- Update README