taksu-tech/laravel-restful

Restful extension for Laravel by Taksu Tech
16,773
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

gabrieloliverio/laravel5-generators

Database metadata-based generators for Laravel 5

1
erirk/paypalpayment

laravel-paypalpayment is simple package help you process direct credit card paym...

0
doctrine/dbal

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

628,058,007 9,707
laravel/framework

The Laravel Framework.

576,155,700 34,907
laravel/tinker

Powerful REPL for the Laravel framework.

485,678,092 7,440