Download the PHP package zealous-creations/tranquil-model-controller without Composer
On this page you can find all versions of the php package zealous-creations/tranquil-model-controller. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zealous-creations/tranquil-model-controller
More information about zealous-creations/tranquil-model-controller
Files in zealous-creations/tranquil-model-controller
Package tranquil-model-controller
Short Description description
License MIT
Informations about the package tranquil-model-controller
Tranquil Models and Controllers
This package contains base Laravel Eloquent models and controllers that contain all the functionality you'll need for CRUD operations. Making Laravel development a more "Tranquil" experience.
Compatible with Laravel 10, 11, and 12
Install
Require it with composer
NOTE: If you have installed
inertiajs/inertia-laravel
lower thanv0.6
ordoctrine/dbal
lower thanv3.0
then you may need to remove them before requiringzealous-creations/tranquil-model-controller
Publish migrations
There are 2 migrations in this package for creating a users
table and an attachments
table
If you want to modify these migrations be for running them, then run this artisan command:
Usage
Tranquil Controller
The Tranquil Controller takes care of all the methods of a standard Laravel controller: index
, create
, show
, edit
, store
, and destroy
For any of your model controllers all you have to do is extend TranquilController
Then all you need to do is add the resource routes for the model.
Now all of the endpoints for the resource routes will automatically work - without having to add any methods to your controller.
Show Endpoint Example
GET /cars/1
Update Endpoint Example
PATCH /cars/1 PAYLOAD {"year": 2024}
This will update year
column of the cars
record that has the id of 1
- As long as the year
is included in the $fillable
model parameter.
Or if you have the model extend TranquilModel
Store Endpoint Example
POST /cars PAYLOAD {"make": "Tesla", "model": "Model S", year": 2024}
This will create a new record in the cars
table. You can have automatic input validation if the model extends TranquilModel
or uses the HasValidation
trait.
List Endpoint
There is also a list
route endpoint you can add for fetching a list of records for the model
Example
POST /cars/list PAYLOAD {"where": {"make": "Buick"}}
Tranquil Inertia Controller
You can return Inertia responses for all the standard controller methods by extending the TranquilInertiaController
Now all of the endpoints will return an Inertia
response to the corresponding component path.
User Model
This package also comes with a TranquilUser
model that is for the authenticated user.
You can extend this model to modify it:
All versions of tranquil-model-controller with dependencies
inertiajs/inertia-laravel Version >=0.6 <3.0
laravel/sanctum Version >=3.0 <5.0