😆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
Đã có lần sử dụng ở dự án nào đấy không rõ, được lấy một phần nhỏ trong dự án trên github
C:\xampp82\htdocs\lva4\Modules\Category\Http\Controllers\CategoryController.php
public function store(CreateCategoryRequest $request)
{
$inputs = $request->all();
Category::create($inputs);
return to_route('category.index');
}C:\xampp82\htdocs\lva4\Modules\Category\Database\Migrations\2023_10_23_043505_create_categories_table.php
<?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');
}
};
C:\xampp82\htdocs\lva4\Modules\Category\Http\Requests\CreateCategoryRequest.php
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
Was this helpful?