some work on models

This commit is contained in:
2018-07-14 14:34:17 +02:00
parent 6fd1d7eb89
commit 7493d3e176
7 changed files with 138 additions and 0 deletions
+28
View File
@@ -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');
}
}