An open API service indexing awesome lists of open source software.

https://github.com/greabock/tentacles

laravel package
https://github.com/greabock/tentacles

php tentacle

Last synced: over 1 year ago
JSON representation

laravel package

Awesome Lists containing this project

README

          

# tentacles
*Monkey-patching for eloquent models*

Composer
```
"greabock/tentacles": "dev-master"
```

user-model...
```php
namespace App\User\Models;

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

User extends Model {

use EloquentTentacle;

}

```

ServiceProvider

```php
hasMany(Article::class);
});

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

}

```

Now we can do this:

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

$fullname = $user->fullname;
```