nevestul4o / network-controller
A basic API controller set for laravel
Installs: 305
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/nevestul4o/network-controller
Requires
- php: ^8.0.2
- ext-imagick: *
- laravel/framework: ^9.0|^10.0|^11.0|^12.0
- league/fractal: ^0.19.0|^0.20.0
Requires (Dev)
- orchestra/testbench: ^10.1.0
- dev-master
- v2.8.0
- v2.7.0
- v2.6.3
- v2.6.2
- v2.6.1
- v2.6.0
- v2.5.2
- v2.5.1
- v2.5.0
- v2.3.9
- v2.3.8
- v2.3.7
- v2.3.6
- v2.3.5
- v2.3.4
- v2.3.3
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.8
- v2.1.7
- v2.1.6
- v2.1.5
- v2.1.4
- v2.1.3
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.9
- v2.0.8
- v2.0.7
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.5.5
- v1.5.4
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.9
- v1.4.8
- v1.4.7
- v1.4.6
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.1
- v1.2.0
- v1.1.0
- v1.0.1
- v1.0.0
- dev-develop
- dev-translations_attempt
This package is auto-updated.
Last update: 2025-12-17 14:32:23 UTC
README
A Laravel package that provides a powerful, convention-driven base API controller and model foundation for building RESTful endpoints quickly. It includes rich GET query capabilities (pagination, filtering, sorting, search, includes, aggregations), transformers via Fractal, file and image upload helpers, ready-made auth controllers, and more.
Table of Contents
- Requirements
- Installation
- Publish Configuration
- Quick Start
- Models (BaseModel)
- Special Features and Aggregations
- File and Image Uploads
- Auth Controllers (Login and Change Password)
- GET Requests Reference
- Contributing
- License
Requirements
- PHP: ^8.0.2
- Laravel: ^9.0 | ^10.0 | ^11.0 | ^12.0
- Extensions: ext-imagick (required for image features)
Installation
Install via Composer:
composer require nevestul4o/network-controller
Publish Configuration
The package ships with a publishable configuration file. Use:
php artisan vendor:publish --provider="Nevestul4o\NetworkController\NetworkControllerServiceProvider"
This will publish:
- config/networkcontroller.php
Quick Start
- Create a controller that extends NetworkController and register a resource route:
use App\Http\Controllers\Controller; use Nevestul4o\NetworkController\NetworkController; class APIEmployeeController extends NetworkController {}
In routes/api.php:
use App\Http\Controllers\APIEmployeeController; use Illuminate\Support\Facades\Route; Route::resource('employee', APIEmployeeController::class);
- Create a model that extends BaseModel and place it under
App\Http\Models(as expected by this package):
namespace App\Http\Models; use Nevestul4o\NetworkController\Models\BaseModel; class Employee extends BaseModel { protected $fillable = ['first_name', 'last_name']; }
- Optional: Add a Fractal transformer for your model and configure includes as needed.
Now you can call endpoints like GET /api/employee with rich query parameters (see reference below).
Models (BaseModel)
- Abstract class; your application models should extend it.
- Expected location:
App\Http\Models. - Ideally, one model maps to one controller that extends NetworkController.
Special Features and Aggregations
- Advanced ordering (including virtual keys via scopes)
- Safe, predefined aggregations returned under meta.aggregate
Read more and see examples: BaseModel — Examples.
File and Image Uploads
Add these routes to routes/api.php:
use Nevestul4o\NetworkController\Controllers\ImagesController; use Nevestul4o\NetworkController\Controllers\UploadController; Route::get('images/{width}/{name}', [ImagesController::class, 'getImage'])->name('get-image'); Route::post('upload', [UploadController::class, 'uploadSubmit']);
Configure your .env:
UPLOADS_PATH=../uploads/files
IMAGES_PATH=../uploads/images
IMAGES_RESIZED_PATH=../cache/images
IMAGES_SUPPORTED_SIZES=300,600,900
IMAGES_REMOVE_METADATA=TRUE
Maintenance command to clear the resized image cache:
php artisan network-controller:images-clear-cache
Auth Controllers (Login and Change Password)
- Pre-made controllers offering login/logout and password change flows.
- Requires a
Usermodel underApp\Http\ModelsextendingBaseUser. - Update the user provider namespace in config/auth.php to
App\Http\Models\User. - Requires a
UserTransformerunderApp\Http\Models\Transformers. - You can override methods as needed.
Routes (add to routes/api.php):
use Nevestul4o\NetworkController\Controllers\Auth\LoginController; use Nevestul4o\NetworkController\Controllers\Auth\ChangePasswordController; Route::post('login', [LoginController::class, 'login'])->name('login'); Route::get('login', [LoginController::class, 'login'])->name('getCurrentUser'); Route::post('logout', [LoginController::class, 'logout'])->name('logout'); Route::post('change-password', [ChangePasswordController::class, 'changePassword'])->name('changePassword'); Route::post('change-password-forced', [ChangePasswordController::class, 'changePasswordForced'])->name('changePasswordForced');
Warning: changePasswordForced in ChangePasswordController is NOT secured. It can change a user's password without the current password. Protect the route appropriately or override the method.
GET Requests Reference
For detailed documentation of the supported GET parameters (pagination, showMeta, sorting, filtering, search, resolve/includes, slugs, aggregations, and more), see:
These docs explain how to use parameters like page, limit, orderby, sort, filters, query, resolve, aggregate and how meta.route_info helps discover allowed values.
Contributing
Issues and pull requests are welcome. Please follow the conventional code style and include tests where possible.
License
MIT