Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hnhdigital-os/laravel-model-traits
Provides a collection of useful traits for Laravel Eloquent models.
https://github.com/hnhdigital-os/laravel-model-traits
Last synced: 11 days ago
JSON representation
Provides a collection of useful traits for Laravel Eloquent models.
- Host: GitHub
- URL: https://github.com/hnhdigital-os/laravel-model-traits
- Owner: hnhdigital-os
- License: mit
- Created: 2016-06-15T15:26:12.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-21T12:20:32.000Z (over 6 years ago)
- Last Synced: 2024-12-13T20:54:56.417Z (about 2 months ago)
- Language: PHP
- Size: 34.2 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel Model Traits Collection
Provides a collection of useful traits for Laravel Eloquent models.
This package has been developed by H&H|Digital, an Australian botique developer. Visit us at [hnh.digital](http://hnh.digital).
## Install
Via composer:
`$ composer require hnhdigital-os/laravel-model-traits ~1.0`
## Usage
### Model savingAdd or save a model with model based attribute rules.
```php
use Bluora\LarvelModelTraits\ModelValidationTrait;class User extends Model
{
use ModelValidationTrait;}
```### Model events
Automatically call an event for created and updated on a model.
```php
use Bluora\LarvelModelTraits\ModelEventsTrait;class User extends Model
{
use ModelEventsTrait;}
```### OrderBy
Adds
* Model default ordering
* Relation based ordering
* Supports raw input.```php
use Bluora\LarvelModelTraits\OrderByTrait;class User extends Model
{
use OrderByTrait;protected $default_order_by = 'name';
protected $default_order_direction = 'asc';
}
``````
$model->order('FIELD(status,3,2,1)', 'desc');
$model->order('other_model.status', 'desc');```
### Model state (Active, Archived, Deleted) Support
Adds support for functions relating to the state of a model provided by the [Eloquent ORM](http://laravel.com/docs/eloquent).
The feature is exposed through a trait by casting your UUID columns as `uuid`.
```php
use Bluora\LarvelModelTraits\ModelStateTrait;class User extends Model
{
use ModelStateTrait;}
```## Contributing
Please see [CONTRIBUTING](https://github.com/hnhdigital-os/laravel-model-traits/blob/master/CONTRIBUTING.md) for details.
## Credits
* [Rocco Howard](https://github.com/RoccoHoward)
* [All Contributors](https://github.com/hnhdigital-os/laravel-model-traits/contributors)## License
The MIT License (MIT). Please see [License File](https://github.com/hnhdigital-os/laravel-model-traits/blob/master/LICENSE) for more information.