What we should notice inside this TagCrudController is that:
As we can tell from the comments there, in most cases we shouldn’t use $this->crud->setFromDb(), which automagically figures out which columns and fields to show. That’s because for real models, in real projects, it would never be able to 100% figure out which field types to use. Real projects are very custom – that’s a fact. In real projects, models are complicated, use a bunch of fields types and you’ll want to customize things. Instead of using setFromDb() then gradually changing what you don’t like, we heavily recommend you manually define all fields and columns you need.

The request

Backpack will also generate a standard FormRequest file, that you can use for validation of the Create and Update forms. There is nothing Backpack-specific in here, but let’s take a look at the generated app/Http/Requests/TagCrudRequest.php file:

This file is a 100% pure FormRequest file – all Laravel, nothing particular to Backpack. In generated FormRequest files, no validation rules are imposed by default. But we do want name to be required and unique, so let’s do that, using the standard Laravel validation rules:

發佈留言

What we should notice inside this TagCrudController is that:
As we can tell from the comments there, in most cases we shouldn’t use $this->crud->setFromDb(), which automagically figures out which columns and fields to show. That’s because for real models, in real projects, it would never be able to 100% figure out which field types to use. Real projects are very custom – that’s a fact. In real projects, models are complicated, use a bunch of fields types and you’ll want to customize things. Instead of using setFromDb() then gradually changing what you don’t like, we heavily recommend you manually define all fields and columns you need.

The request

Backpack will also generate a standard FormRequest file, that you can use for validation of the Create and Update forms. There is nothing Backpack-specific in here, but let’s take a look at the generated app/Http/Requests/TagCrudRequest.php file:

This file is a 100% pure FormRequest file – all Laravel, nothing particular to Backpack. In generated FormRequest files, no validation rules are imposed by default. But we do want name to be required and unique, so let’s do that, using the standard Laravel validation rules:

發佈留言