taksu-tech / laravel-restful
Restful extension for Laravel by Taksu Tech
Installs: 4 074
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- laravel/framework: >=9.0
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,
]);
}
}