In this lesson, let's show a column from the relationship in the posts table. We will add a category for every post.
First, we need to create a Category
model and migration.
php artisan make:model Category -m
database/migrations/xxxx_create_categories_table.php:
public function up(): void{ Schema::create('categories', function (Blueprint $table) { $table->id(); $table->string('name'); $table->timestamps(); });}
app/Models/Category.php:
class Category extends Model{ protected $fillable = [ 'name', ];}
Next, we need to create a migration...