-
Notifications
You must be signed in to change notification settings - Fork 49
Basic CRUD Validation
JP Barbosa edited this page Mar 14, 2016
·
3 revisions
php artisan make:request ArticleRequest
nano app/Http/Requests/ArticleRequest.php
...
public function authorize()
{
return true;
}
public function rules()
{
return [
'title' => 'required|min:3',
'content' => 'required',
];
}
...
nano app/Http/Controllers/ArticlesController.php
namespace App\Http\Controllers;
use App\Http\Requests\ArticleRequest;
use App\Article;
class ArticlesController extends Controller
{
...
public function store(ArticleRequest $request)
...
public function update(ArticleRequest $request, Article $article)
...
}
php artisan serve
curl -H "Accept: application/json" \
http://localhost:8000/articles \
--data "title=A" \
--data "content=Article Content"
{"title":["The title must be at least 3 characters."]}
curl -H "Accept: application/json" \
http://localhost:8000/articles \
--data "title=Article Title" \
--data "content=Article Content"
{"title":"Article Title","content":"Article Content"...}
git add .
git commit -m "Add articles validations"
Next step: Views
- 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