cascadeOnDelete()
The cascadeOnDelete()
method is a convenient way to define cascading behavior for foreign keys when a referenced record is deleted.
Behavior
- Automatically deletes the rows in the child table if the related row in the parent table is deleted.
Example
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->timestamps();
});
This ensures that if a user is deleted, all their related posts will also be deleted.
Status: #idea
Tags: web-programmingWeb Programming (Laravel)here are the mid exam materials
I understand it NOW
Final Exam Materials
Mid Exam Materials
Initialization
composer create-project laravel/laravel newProject
not necessary since no wifi and project might be already given
Database
Setup Database
1. Open .env file and look for DB_.. and make sure its the same as this
DB_CONNECTION=mysql // XAMPP runs mysql database engine
DB_HOST=127.0.0.1
DB_PORT=3306 // port for database
DB_DATABASE=laravelproject // make a new database name
DB_USERNA