use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { public function up() { Schema::create('tablename', function (Blueprint $table) { $table->id(); $table->timestamps(); }); } public function down() { Schema::dropIfExists('tablename'); } }; 14/40
// Scopes the second Eloquent model // that it must be a child of the first Eleoquent model Route::get('users/{user}/posts/{post}', function (User $user, Post $post) { return $post; })->scopeBindings(); 26/40
// Laravel 8 class User extends Model { public function getFirstNameAttribute() { return ucfirst($this->first_name); } public function setFirstNameAttribute($value) { $this->attributes['first_name'] = strtolower($value); } } 38/40
// Laravel 9 use Illuminate\Database\Eloquent\Casts\Attribute; class User extends Model { public function firstName(): Attribute { return new Attribute( get: fn ($value) => ucfirst($value), set: fn ($value) => strtolower($value), ); } } 39/40