dan/laravel-more

More for your Laravel projects.
18,406
Install
composer require dan/laravel-more
Latest Version:v0.3.1
PHP:>=7.0
License:MIT
Last Updated:Mar 30, 2026
Links: GitHub  ·  Packagist
Maintainer: dan

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\Model that extends More\Laravel\Model or do à la carte, and use \More\Laravel\Traits\Model\* as needed.
  • Or extend \More\Laravel\Model if you're really lazy.
  • Or use traits on specific models...blerg.

Contributors

License

MIT.

Related Packages

laravel/pint

An opinionated code formatter for PHP.

193,276,818 3,166
tightenco/duster

Automatic configuration for Laravel apps to apply Tighten's standard linting & c...

3,126,069 604
directorytree/ldaprecord-laravel

LDAP Authentication & Management for Laravel.

2,698,585 575
hemp/presenter

Easy Model Presenters in Laravel

636,598 247
juzaweb/cms

Juzaweb CMS is a Content Management System (CMS) developed based on Laravel Fram...

571,270 190