Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8ffdb5
commit 9e0fa4b
Showing
3 changed files
with
38 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,28 @@ | |||
<?php | |||
|
|||
namespace App\Concerns; | |||
|
|||
use App\Synchronization; | |||
|
|||
trait Synchronizable | |||
{ | |||
public static function bootSynchronizable() | |||
{ | |||
// Start a new synchronization once created. | |||
static::created(function ($synchronizable) { | |||
$synchronizable->synchronization()->create(); | |||
}); | |||
|
|||
// Stop and delete associated synchronization. | |||
static::deleting(function ($synchronizable) { | |||
optional($synchronizable->synchronization)->delete(); | |||
}); | |||
} | |||
|
|||
public function synchronization() | |||
{ | |||
return $this->morphOne(Synchronization::class, 'synchronizable'); | |||
} | |||
|
|||
abstract public function synchronize(); | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters