- php artisan serve
- php artisan migrate
- php artisan make:model Model -m
- php artisan make:controller ExampleController --resource
- php artisan tinker
- MVC model
- Authentication
- Storing SQL database
- Setup composer
- Setup Laravel Jetstream
The name store in the database should be capitalized each word (ex: My Name) eventhought the staff insert all lowercase or uppercase (Tips: Convert in Model)
public function setNameAttribute($value)
{
$this->attributes['name'] = strtoupper($value);
}
Each branch has many fire extinguishers
public function fireExtinguisher(){
return $this->hasMany(FireExtinguisher::class);
}
Each fire extinguisher belongs to one branch
public function branch(){
return $this->belongsTo(Branch::class, 'location', 'id');
}
Schema::create('fire_extinguishers', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('location');
$table->date('expiry_date');
$table->string('serial_numbers');
$table->string('type');
$table->float('weight');
$table->string('brand');
$table->timestamps();
$table->foreign('location')
->references('id')
->on('branches')
->onDelete('cascade');
});
public function store(Request $request)
{
$fireExtinguisher = FireExtinguisher::create([
'location' => $request->input('location'),
'expiry_date' => $request->input('expiry_date'),
'serial_numbers' => $request->input('serial_numbers'),
'type' => $request->input('type'),
'weight' => $request->input('weight'),
'brand' => $request->input('brand'),
]);
return redirect('/fire-extinguishers');
}
- Complete Laravel 8 Tutorial | Laravel 8 From Scratch | Full Laravel 8 Course | Laravel For Beginners
MIT
This website is built with โค๏ธโ๐ฅ by Hovah!