Using morphTo() on services, added Ezypay payment Import
This commit is contained in:
@@ -2,9 +2,13 @@
|
||||
|
||||
/**
|
||||
* Works out the next ID to use for an Eloquent Table.
|
||||
*
|
||||
* If we update records, we update the record_id table
|
||||
*/
|
||||
namespace App\Traits;
|
||||
|
||||
use App\Models\Module;
|
||||
|
||||
trait NextKey
|
||||
{
|
||||
public static function boot()
|
||||
@@ -15,6 +19,16 @@ trait NextKey
|
||||
{
|
||||
$model->id = self::NextId();
|
||||
});
|
||||
|
||||
static::saved(function($model)
|
||||
{
|
||||
if (! $model::RECORD_ID)
|
||||
throw new \Exception('Missing record_id const for '.get_class($model));
|
||||
|
||||
$mo = Module::where('name',$model::RECORD_ID)->firstOrFail();
|
||||
$mo->record->id = $model->id;
|
||||
$mo->record->save();
|
||||
});
|
||||
}
|
||||
|
||||
public static function NextId()
|
||||
|
Reference in New Issue
Block a user