Laravel Basic
Laravel Form
Laravel Database
Laravel Advance
Generate a model with Artisan:
php artisan make:model Post
This generates a file in app/Models/:
By default:
Post
model → posts
table<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Post extends Model { // }
class Post extends Model { protected $fillable = ['title', 'content', 'is_published', 'published_at']; }
Use $fillable to define mass-assignable fields:
protected $fillable = ['title', 'content'];
(OR)
protected $guarded = [];
to block mass assignment for specific fields.