https://github.com/greabock/tentacles
laravel package
https://github.com/greabock/tentacles
php tentacle
Last synced: over 1 year ago
JSON representation
laravel package
- Host: GitHub
- URL: https://github.com/greabock/tentacles
- Owner: greabock
- Created: 2015-02-16T10:44:41.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2021-02-03T08:46:27.000Z (over 5 years ago)
- Last Synced: 2025-02-27T12:05:44.627Z (over 1 year ago)
- Topics: php, tentacle
- Language: PHP
- Homepage:
- Size: 12.7 KB
- Stars: 37
- Watchers: 5
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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;
```