taksu-tech/laravel-restful

Restful extension for Laravel by Taksu Tech
17,206
Install
composer require taksu-tech/laravel-restful
Latest Version:v1.1.12
License:MIT
Last Updated:Aug 22, 2026
Links: GitHub  ·  Packagist
Maintainer: madeadi

Laravel Restful

Install

composer require taksu-tech/laravel-restful

Taksu\RestfulServiceProvider is auto-discovered, no manual registration needed.

CRUD Controller

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,
        ]);
    }
}

Migrations

This package ships publishable migrations for its optional features (multi-tenancy, running numbers). Publish and run them with:

php artisan vendor:publish --tag=restful-migrations
php artisan migrate

Multi-tenancy

Use TenantAware on a model to automatically scope queries to the current tenant, stamp tenant_id on create, and hide it from serialized output.

use Taksu\Tenant\TenantAware;

class Admin extends Model
{
    use TenantAware;
    ...
}

Requirements:

  • The model's table needs a tenant_id column (see Migrations).
  • Taksu\Tenant\CurrentTenant resolves the tenant from Auth::user()?->tenant_id, so your authenticated user model must expose a tenant_id attribute.

Running numbers

Use HasRunningNumber on a model to auto-generate a padded, prefixed, per-tenant sequential number on create (e.g. invoice numbers).

use Taksu\RunningNumber\HasRunningNumber;

class Invoice extends Model
{
    use HasRunningNumber;

    protected $runningNumberColumn = 'number'; // default: 'number'
    protected $runningNumberPrefix = 'INV-';   // default: ''
    protected $runningNumberPadding = 6;       // default: 6
}

This requires the running_number_sequences table (see Migrations). Sequences are scoped per tenant_id when the model uses TenantAware, or globally otherwise.

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

637,827,751 9,703
laravel/framework

The Laravel Framework.

589,172,971 34,950
laravel/tinker

Powerful REPL for the Laravel framework.

498,216,183 7,442
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

413,412,504 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

394,964,158 4,660

Version History

Version Released Laravel License
v1.1.12 >=13.0 MIT
v1.1.11 >=13.0 MIT
v1.1.10 >=13.0 MIT
v1.1.9 >=9.0 MIT
v1.1.8 >=9.0 MIT