モデルとマイグレーションファイルの作成
sail artisan make:model Post -m<プロジェクトフォルダ>/database/migrations の中に
日付create_Post_table.phpが作成される。
public function up(): void
{
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->string('title'); //追加
$table->text('body'); //追加
$table->timestamps();
});
}ビューファイルの作成
<プロジェクトフォルダ>/resouces/viewsの中にpostフォルダを作成し、その中に
create.blade.phpを作成。
ビューファイルを作る。
コントローラーの作成
sail artisan make:controller PostControllerapp/Http/Controllerの中に、PostControllerが作成されるのでビューファイルをを表示させる記述を行う。
class PostController extends Controller
{
public function create(){
return view('post.create');
}
}ルートの設定
<プロジェクトフォルダ>/routes/web.phpに追記。
Route::get('post/create',[PostController::class,'create']);
