Laravel 10.x Create tags crud

Lyubomir Filipov
2 min readDec 11, 2023

--

To proceed you should have

  • Laravel installed + Backpack admin (teaching purposes)

If you are interested in seeing information related to older versions you could find them here (create migration Laravel 9.x) and here (create CRUD — Laravel 9.x).

#STEP 1. Create migration

php artisan make:migration create_tags_table

#STEP 2. Alter migration file

Schema::create('tags', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->string('slug')->unique();
$table->timestamps();
});

#STEP 3. Run migration command

php artisan migrate

The command will create the table for you and also update the migrations table.

#STEP 4. Create CRUD

php artisan backpack:crud tag

It will generate a couple of files that you need for your CRUD.

#STEP 5. Alter requests file

If there is no validation

Note: We are using a requests file for validation and we are currently altering TagRequest.php located in app/Http/Requests folder

 /**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required|min:5|max:255',
'slug' => 'required|min:5|max:255'
];
}

You can find all sorts of pre-built validation rules here.

Well, we are ready. It is that easy.

--

--

Lyubomir Filipov
Lyubomir Filipov

Written by Lyubomir Filipov

Group Architect at FFW, believer, developer, enthusiast

No responses yet