Download the PHP package engency/resource-controllers without Composer
On this page you can find all versions of the php package engency/resource-controllers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download engency/resource-controllers
More information about engency/resource-controllers
Files in engency/resource-controllers
Package resource-controllers
Short Description Resource Controllers for Laravel
License MIT
Informations about the package resource-controllers
Laravel Resources
Don't waste valuable time on writing basic CRUD operations for your Laravel application.
Ideology
Most CRUD operations are very straight-forward, especially when conforming to the REST design. As long as a few basic rules are met, generic logic can do the trick.
- Middleware authorizes users for operations on resources
- The controller determines the scope
- Rules validate input before storing and updating resources
- Rules make sure clients will only receive the attributes they are authorized to see
For applications with both an API and 'general' webinterface, you ideally just want a single controller performing the basic crud operations on a resource. Therefore, generic logic should be able to construct responses in both HTML and JSON format.
Requirements
- PHP 7.1+ | PHP 8+
- The Laravel framework
Installation
Alongside this package, the engency/eloquent-formatting and engency/laravel-model-validation package will be installed.
Usage
The most basic setup could look as following;
The controller
The model
Html response
The controller will find for the following views;
- resource-path/views/pages/resource-name-kebab-case/index.blade.php
- resource-path/views/pages/resource-name-kebab-case/create.blade.php
- resource-path/views/pages/resource-name-kebab-case/show.blade.php
- resource-path/views/pages/resource-name-kebab-case/edit.blade.php
Within the index.blade.php file, the $items variable will be present by default. The index.blade.php file could look as following;
Any page showing a resource (show and edit) have access to the resource. The name of the variable is the name of the resource, in camel case. E.g., 'StreetSign' would be '$streetSign'. The show.blade.php file could look like this;
In addition to that, the controller uses specific error pages;
- resource-path/views/pages/error/unauthorized.blade.php
- resource-path/views/pages/error/notfound.blade.php
- resource-path/views/pages/error/conflict.blade.php
- resource-path/views/pages/error/forbidden.blade.php
- resource-path/views/pages/error/500.blade.php
JSON response
Response for the index call
Contributors
- Frank Kuipers (GitHub)
- Feel free to contribute or submit feature-requests as issues.
License
This plugin is licenced under the MIT license.
All versions of resource-controllers with dependencies
illuminate/http Version ^8.0|^9.0
illuminate/routing Version ^8.0|^9.0
illuminate/database Version ^8.0|^9.0
illuminate/view Version ^8.0|^9.0
engency/eloquent-formatting Version ^0.2.0
engency/laravel-model-validation Version ^0.2.0