v.2.4
Restore shifts
This commit is contained in:
29
models/Subscriber.php
Normal file
29
models/Subscriber.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Component\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Subscriber extends Model {
|
||||
protected $table = 'subscribers';
|
||||
public $timestamps = false;
|
||||
|
||||
public static function add($event, $callback, $weight = 0) {
|
||||
list($destination_module, $destination_method) = explode(':', $callback);
|
||||
list($source_module, $source_method) = explode(':', $event);
|
||||
|
||||
$code = strtolower($destination_module . '_' . $destination_method . '_after_' . $source_module . '_' . $source_method);
|
||||
|
||||
if (Subscriber::where('code', $code)->count() == 0) {
|
||||
$subscriber = new Subscriber([
|
||||
'code' => $code,
|
||||
'destination_module' => strtolower($destination_module),
|
||||
'destination_method' => strtolower($destination_method),
|
||||
'source_module' => strtolower($source_module),
|
||||
'source_method' => strtolower($source_method),
|
||||
'weight' => $weight,
|
||||
]);
|
||||
$subscriber->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user