dan/laravel-more
More (for Laravel)
Why more? Because I seem to use it in all my Laravel projects. And who doesn't want more Laravel? ;p
Highlights
compact()
Example for compact(), with say, a payment...
$user->update($payment->compact());
// is the same as
$user->update(['payment_id' => $payment->getKey()]);
// or if your field was `default_payment_id` instead of `payment_id`...
$user->update($payment->compact('default_payment');
unmorph($as = null)
The unmorph($as) function is similar to compact()...
$order->update($transaction->unmorph('charge'));
// is the same as
$order->update(['charge_id' => $transaction->getKey(), 'charge_type' => get_class($transaction)]);
BelongsToUser
How often do your models belong to User... a lot, right?
class Post extend Model
{
use BelongsToUser;
}
Usage
$post->user() // BelongsTo
$post->user // App\User
$post->isAccessibleBy($user) // boolean
Post::forUser($user) // Builder|Post
Post::forUsers($arr_or_col) // Builder|Post
Post::createForUser($user, [...]) // Post
And of course there is more included
The \More\Laravel\Traits\Model\Core namespace is reasonable for global usage.
The \More\Laravel\Traits\Model namespace is for the per model use cases.
Good Luck!
Composer
$ composer require dan/laravel-more dev-master
Implementation options
Do you have a base model? e.g. App\Model
Yes
- Add the traits you like to base model.
- Or extend \More\Laravel\Model
No
- Make a base model
\App\Modelthat extendsMore\Laravel\Modelor do à la carte, anduse \More\Laravel\Traits\Model\*as needed. - Or extend
\More\Laravel\Modelif you're really lazy. - Or use traits on specific models...blerg.
Contributors
License
MIT.
Related Packages
tightenco/duster
Automatic configuration for Laravel apps to apply Tighten's standard linting & c...
3,273,308
604
juzaweb/cms
Juzaweb CMS is a Content Management System (CMS) developed based on Laravel Fram...
571,275
191
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v0.3.1 | >=7.0 | ^5.5| | MIT | |
| v0.3 | >=7.0 | ^5.5| | MIT | |
| v0.2.17 | >=7.0 | ^5.5| | MIT | |
| v0.2.16 | >=7.0 | ^5.5| | MIT | |
| v0.2.14 | >=7.0 | ^5.5| | MIT | |
| v0.2.13 | >=7.0 | ^5.5| | MIT | |
| 0.2.12 | >=7.0 | ^5.5| | MIT | |
| v0.2.11 | >=7.0 | ^5.5| | MIT | |
| v0.2.10 | >=7.0 | ^5.5| | MIT | |
| v0.2.9 | >=7.0 | ^5.5| | MIT | |
| v0.2.8 | >=7.0 | ^5.5| | MIT | |
| v0.2.7 | >=7.0 | 5.8.*| | MIT | |
| v0.2.6 | >=7.0 | 5.8.*| | MIT | |
| v0.2.5 | >=7.0 | 5.8.* | MIT | |
| v0.2.4 | >=7.0 | 5.8.* | MIT | |
| v0.2.0 | >=7.0 | 5.8.* | MIT | |
| v0.1.0 | >=5.6 | 5.3.*| | MIT | |
| v0.0.19 | >=5.6 | 5.3.*| | MIT | |
| v0.0.18 | >=5.6 | 5.3.*| | MIT | |
| v0.0.17 | >=5.6 | 5.3.*| | MIT | |
| v0.0.16 | >=5.6 | 5.3.*| | MIT | |
| v0.0.14 | >=5.6 | 5.3.*| | MIT | |
| v0.0.13 | >=5.6 | 5.3.*| | MIT | |
| v0.0.12 | >=5.6 | 5.3.*| | MIT | |
| v0.0.11 | >=5.6 | 5.3.*| | MIT | |
| v0.0.10 | >=5.6 | 5.3.*| | MIT | |
| v0.0.9 | >=5.6 | 5.3.*| | MIT | |
| 0.0.8 | >=5.6 | 5.3.*| | MIT | |
| v0.0.7 | >=5.6 | 5.3.*| | MIT | |
| v0.0.6 | >=5.6 | 5.3.*| | MIT |
Showing the latest 30 of 35. See every release on Packagist