laravelを学ぶ機会があったので、簡単にまとめたいと思います。
全体像
CRUD処理
CRUD処理とは
システムに必要な4つの主要機能である
「Create(生成)」「Read(読み取り)」「Update(更新)」「Delete(削除)」
の頭文字を並べた用語です。
HTTPメソッドを指定するルーティング
GET ・・・ (データを取得する基本的なもの)
POST ・・・ (データの追加に使用)
PUT ・・・ (データの更新に使用)
DELETE ・・・ (データの削除に使用)
※他もある
アクション
実装例
routes/web.php
Route::get('/', 'PostsController@index');
Route::get('posts/new', 'PostsController@create')->name('posts.create');
Route::post('posts', 'PostsController@store')->name('posts.store');
Route::get('post/{id}/edit', 'PostsController@edit')->name('post.edit');
Route::post('post/{id}', 'PostsController@update')->name('post.update');
Route::delete('post/{id}', 'PostsController@destroy')->name('post.destroy');
↧