wever / laradot
A library built on top of the Laravel framework to enhance development.
Requires
- php: ^8.0
- ext-gd: *
- illuminate/database: ^9.0|^10.0|^11.0
- illuminate/http: ^9.0|^10.0|^11.0
- illuminate/support: ^9.0|^10.0|^11.0
- intervention/image: ^3.0
- nesbot/carbon: ^2.0|^3.0
- dev-main
- v7.x-dev
- v7.0.2
- v7.0.1
- v7.0
- v6.0.2
- v6.0.1
- v6.0.0
- v5.2.0
- v5.1.5
- v5.1.4
- v5.1.3
- v5.1.2
- v5.1.1
- v5.1.0
- v5.0.0
- v4.0.14
- v4.0.13
- v4.0.12
- v4.0.11
- v4.0.10
- v4.0.9
- v4.0.8
- v4.0.7
- v4.0.6
- v4.0.5
- v4.0.4
- v4.0.3
- v4.0.2
- v4.0.1
- v4.0
- v3.1.4
- v3.1.3
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.20
- v3.0.19
- v3.0.18
- v3.0.17
- v3.0.16
- v3.0.15
- v3.0.14
- v3.0.13
- v3.0.12
- v3.0.11
- v3.0.10
- v3.0.9
- v3.0.8
- v3.0.7
- v3.0.6
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v2.0.2
- v2.0.1
- v2.0.0
- v1.0.24
- v1.0.23
- v1.0.22
- v1.0.21
- v1.0.20
- v1.0.19
- v1.0.18
- v1.0.17
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.12
- v1.0.11
- v1.0.1
- v1.0.0
This package is auto-updated.
Last update: 2026-04-19 23:52:11 UTC
README
Laradot is a library built on top of the Laravel framework, designed to optimize the structure and development flow of applications. Below are the key features and design patterns implemented in Laradot.
1. Application Structure and Lifecycle
Laradot defines a structured approach to building Laravel applications, with the following components:
- BaseModel: A foundation model that all application models inherit from.
- BaseController: A generic controller that handles CRUD operations and more.
- BaseService: A service layer that contains the business logic for the application.
Application Lifecycle
The lifecycle of an operation within Laradot follows a well-defined path:
- Middlewares: Process any incoming requests.
- FormRequest and Rules: Validate the incoming data.
- Controller: Handle the logic and direct the request to the appropriate service.
- Service: Execute the core operation (create, update, etc.) and handle business logic.
- Resource: Format the data to be returned.
- Response: Return the appropriate response or handle errors.
This lifecycle ensures a clean, structured flow for all operations, resulting in well-designed CRUD operations.
2. MakeFeatureCommand
Laradot introduces the MakeFeatureCommand, an advanced Artisan command that automates the creation of various components in the application lifecycle.
Features of MakeFeatureCommand:
- File Creation: Automatically generates controllers, services, form requests, resources, and other necessary files for a feature.
- Migrations: Creates migrations with pre-defined fields, constraints, and relationships.
- Validation Rules: Generates rules for creating and updating fields directly in the form request, ensuring consistency across operations.
3. Model Features
3.1 Image/File Handling
- Laradot provides an easy-to-use mechanism for declaring that a model stores images or files.
- Automatic discovery in the service layer to manage the storage of files.
3.2 Excel Export
- Convert any response into an Excel file with a simple mechanism.
- This feature integrates seamlessly with the resource layer, allowing for a quick export of data.
3.3 Validation Translation
- Automatically translate all validation messages and keys in form requests.
- Provide multi-language support for validation, enhancing user experience across different locales.
3.4 Deep Filtering
- Add deep filtering mechanisms to any model in seconds.
- This allows for complex query capabilities, enabling users to filter results based on various attributes easily.
- The deep filtering feature also provides an easy and fast way to perform filtering not only across the model itself but also across its related models and relationships.
- This enables powerful, multi-level filtering, giving users fine-grained control over the data they retrieve.
Spatie-style scopes & relations (with Laradot filters)
Laradot offers similar ergonomics to Spatie Query Builder filters: you can filter by model scopes and by related model fields using dot notation under the hood (Laradot uses whereHas automatically).
Model setup
use Wever\Laradot\App\Traits\Filterable;
use Wever\Laradot\App\FilterTypes\{
BooleanFilter,
LikeFilter,
RangeFilter,
ScopeFilter,
WhereInFilter
};
class User extends Model
{
use Filterable;
protected $filterable = [
'name' => LikeFilter::class,
'is_active' => BooleanFilter::class,
'role_id' => WhereInFilter::class,
'created_at' => RangeFilter::class,
'active' => ScopeFilter::class, // calls scopeActive(...)
'company' => Company::class, // enables company.* filters
];
public function scopeActive($query, $value = true)
{
return $query->where('is_active', $value);
}
// Optional negation: ?active=false will call scopeNotActive(true) if it exists
public function scopeNotActive($query, $value = true)
{
return $query->where('is_active', false);
}
}
Examples
- Filter by scope:
/users?active=trueor/users?filter[active]=true - Filter by relation field:
/users?company[name]=Acmeor/users?filter[company][name]=Acme - Filter by range and list:
/users?created_at_from=2024-01-01&created_at_to=2024-12-31&role_id=1,2or/users?filter[created_at][from]=2024-01-01&filter[created_at][to]=2024-12-31&filter[role_id]=1,2
If you want a single relation field without exposing all of that model's filters, you can declare it directly:
protected $filterable = [
'company.name' => LikeFilter::class,
];
For reference, see Spatie Query Builder filtering docs.
Multi-column sorting
Add a sortable list to your model, then sort using bracket params. Order in the query string is the priority order.
class User extends Model
{
use Filterable;
protected $sortable = [
'name',
'created_at',
'email',
];
}
Examples
/users?sort[name][desc]&sort[created_at][asc]/users?sort[created_at][desc]
3.5 Search Mechanism
- Implement an efficient search mechanism for any model in seconds.
- Supports keyword-based searching that can scan through various fields and relationships.
3.6 Automatic Loading of Required Relations
- Laradot solves the issue of forgetting to load necessary relations that the frontend might require.
- It introduces a mechanism where relations required by the frontend can be automatically detected and loaded.
- With Laradot, the frontend can request specific relations dynamically, giving more control over the data they need.
- You can also limit which relations the frontend is allowed to request, ensuring secure and controlled data access.
- This mechanism reduces back-and-forth communication between the frontend and backend, ensuring all necessary relations are included in the response while maintaining security and performance.
Laradot aims to streamline Laravel application development by providing a clear structure and advanced automation tools, reducing development time while maintaining code quality and flexibility.