taksu-tech/laravel-restful

There is no license information available for the latest version (v1.1.4) of this package.

Restful extension for Laravel by Taksu Tech

v1.1.4 2023-06-14 03:28 UTC

This package is auto-updated.

Last update: 2024-05-09 03:54:47 UTC


README

To use

Create a controller class and extends it from CrudController.

Example:

use CommonModelTrait on the model.

class Admin extends Model
{
    use ModelCommonTrait;
    ...
}
namespace App\Http\Controllers;

use App\Models\Admin;
use Taksu\Restful\Controllers\CrudController;

class AdminController extends CrudController
{
    public function __construct()
    {
        parent::__construct(Admin::class);
    }
}

Add in the routes\api.php

Route::apiResource('admins', AdminController::class);

Finally, query the API

GET localhost:8000/api/admins

To install the console commands, in AppServiceProvider, add the following:

public function boot()
{
    if ($this->app->runningInConsole()) {
        $this->commands([
            Taksu\Console\Commands\MakeCrudController::class,
        ]);
    }
}