Wallogit.com
2017 © Pedro Peláez
Allow you to create a simple CRUD controller
Allow you to create a simple CRUD controller, (*1)
composer require efrontsa/easy_crud
After install this package you have to set the service provider on your config/app.php file, (*2)
EFrontSA\EasyCRUD\ServiceProvider::class,
Then you just need to publish files ! Copy and paste it, (*3)
php artisan vendor:publish --provider="EFrontSA\EasyCRUD\ServiceProvider"
That's it!, (*4)
City
$this->view to where your views are located. the trait look for (index, create, edit) views.Ex. :, (*5)
class CityController extends Controller
{
use \EFrontSA\EasyCRUD\Models\BasicCRUDTrait;
public function __construct(City $model) // You can change the model type hint to update the model in this controller
{
$this->model = $model;
$this->view = 'cities'; // where the views located. the trait look for (index, create, edit) views.
app()->bind(CRUDRequest::class, CityRequest::class); // bind your request with CRUDRequest interface
}
}
Your form request should implement this interface \EFrontSA\EasyCRUD\Requests\CRUDRequest, (*6)
class CityRequest extends Request implements CRUDRequest{
}
create your views (index, create, edit)., (*7)
edit view will receive $object variable as the result of model query.index view will receive $objects variable as the result of model query.