2017 © Pedro Peláez
 

project laravel-more

More for your Laravel projects.

image

dan/laravel-more

More for your Laravel projects.

  • Wednesday, July 11, 2018
  • by dan
  • Repository
  • 2 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

More (for Laravel)

Why more? Because I seem to use it in all my Laravel projects. And who doesn't want more Laravel? ;p, (*1)

Highlights

compact()

Example for compact(), with say, a payment..., (*2)

$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()..., (*3)

$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?, (*4)

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., (*5)

The \More\Laravel\Traits\Model namespace is for the per model use cases., (*6)

Good Luck!, (*7)

Composer

$ composer require dan/laravel-more dev-master

Implementation options

Do you have a base model? e.g. App\Model

Yes, (*8)

  • Add the traits you like to base model.
  • Or extend \More\Laravel\Model

No, (*9)

  • 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][1].

Contributors

License

MIT., (*10)

The Versions

11/07 2018

dev-master

9999999-dev

More for your Laravel projects.

  Sources   Download

MIT

The Requires

 

laravel

11/07 2018

0.0.8

0.0.8.0

More for your Laravel projects.

  Sources   Download

MIT

The Requires

 

laravel

12/04 2018

v0.0.7

0.0.7.0

More for your Laravel projects.

  Sources   Download

MIT

The Requires

 

laravel

11/04 2018

v0.0.6

0.0.6.0

More for your Laravel projects.

  Sources   Download

MIT

The Requires

 

laravel

11/04 2018

v0.0.5

0.0.5.0

More for your Laravel projects.

  Sources   Download

MIT

The Requires

 

laravel

22/02 2018

v0.0.4

0.0.4.0

More for your Laravel projects.

  Sources   Download

MIT

The Requires

 

laravel

22/02 2018

v0.0.3

0.0.3.0

More for your Laravel projects.

  Sources   Download

MIT

The Requires

 

laravel

15/02 2018

v0.0.2

0.0.2.0

More for your Laravel projects.

  Sources   Download

MIT

The Requires

 

laravel

15/02 2018

v0.0.1

0.0.1.0

More for your Laravel projects.

  Sources   Download

MIT

The Requires

 

laravel