haegemon / lara-find-events by haegemon

Lara findEvent is a small library that enabled after find event for laravel model
74
0
1
Package Data
Maintainer Username: haegemon
Maintainer Contact: pawel.samysev@gmail.com (haegemon)
Package Create Date: 2015-09-17
Package Last Update: 2018-02-12
Language: PHP
License: GPL-2.0-or-later
Last Refreshed: 2024-11-25 15:02:37
Package Statistics
Total Downloads: 74
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

LaraFindEvent

Small library that enabled after find event at laravel

Installation

Require this package in your composer.json file:

"haegemon/lara-find-events": "dev-master"

...then run composer update to download the package to your vendor directory.

Usage

The feature is exposed through a trait that add new functionality to object. Event handler can be describe any standart way. For example we could create a Photos model like this:


use Eloquent\LaraFindEvents\LaraFindEvents as LaraFindEvents;

class Photo extends Eloquent
{
    use LaraFindEvents;
    
    public static function boot()
    {
        parent::boot();
    
        static::found(function (WildPlant $wildPlant) {
            var_dump('Iamfound', $wildPlant->id);
            return true;
        });
    }
}