some work on models
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Models\Concerns;
|
||||
|
||||
|
||||
use App\Models\ContentReport;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
|
||||
trait Reportable
|
||||
{
|
||||
public function bootReportable()
|
||||
{
|
||||
static::deleting(function(Reportable $self) {
|
||||
$self->reportsOf()->delete();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports of this user
|
||||
*
|
||||
* @return MorphMany
|
||||
*/
|
||||
public function reportsOf()
|
||||
{
|
||||
return $this->morphMany(ContentReport::class, 'object');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user