😆Request đặc biệt, tự làm Request khác với mặc định (ok)
https://github.com/balanchi/Simple-Module-Laravel-Project/tree/master
public function store(CreateCategoryRequest $request)
{
$inputs = $request->all();
Category::create($inputs);
return to_route('category.index');
}<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('categories', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->text('description');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('categories');
}
};
PreviousKHÔNG DÙNG ELOQUENT THÌ DÙNG LARAVEL LÀM GÌ?NextNhững mẹo hay và ngắn chúng ta thường không nhớ sử dụng.
Last updated