2017 © Pedro Peláez
 

library tentacles

Da epic tentacles for Eloquent

image

greabock/tentacles

Da epic tentacles for Eloquent

  • Monday, January 18, 2016
  • by greabock
  • Repository
  • 3 Watchers
  • 27 Stars
  • 9,363 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 0 Open issues
  • 2 Versions
  • 15 % Grown

The README.md

tentacles

Monkey-patching for eloquent models, (*1)

Composer, (*2)

"greabock/tentacles": "dev-master"

user-model..., (*3)

<? namespace App\User\Models;

use Illuminate\Database\Eloquent\Model;
use Greabock\Tentacles\EloquentTentacle;

User extends Model {

  use EloquentTentacle;

}

ServiceProvider, (*4)

<?php namespace App\Article\Providers;

use Illuminate\Support\ServiceProvider;
use App\Article\Models\Article;
use App\User\Models\User;


use Illuminate\Database\Eloquent\Model;

class ArticleProvider extends ServiceProvider {

  public function register()
  {
    #..
  }

  public function boot()
  {
    User::addExternalMethod('articles', function()
    {
        return $this->hasMany(Article::class);
    });


    User::addExternalMethod('getFullnameAttribute', function()
    {
        return $this->first_name . ' ' . $this->last_name; 
    });
  }

}

Now we can do this:, (*5)

$user = User::with('articles')->first();

$fullname = $user->fullname;

The Versions

18/01 2016

dev-master

9999999-dev

Da epic tentacles for Eloquent

  Sources   Download

MIT

The Requires

 

by Avatar greabock

laravel eloquent trait model

18/01 2016

1.0

1.0.0.0

Da epic tentacles for Eloquent

  Sources   Download

MIT

The Requires

 

by Avatar greabock

laravel eloquent trait model