added php sandbox and some helper funcs to models

This commit is contained in:
2018-07-14 15:22:10 +02:00
parent 8efa08b1cc
commit 66afe052b9
16 changed files with 4764 additions and 4 deletions
+13
View File
@@ -25,4 +25,17 @@ trait Reportable
{
return $this->morphMany(ContentReport::class, 'object');
}
/**
* Save a report of this object to the DB
*
* @param string $message explanation why it should be removed
*/
public function reportAsInappropriate($message)
{
$this->reportsOf()->save(new ContentReport([
'author_id' => \Auth::user()->getKey(),
'message' => $message,
]));
}
}
+22
View File
@@ -109,4 +109,26 @@ class User extends Authenticatable
{
return $this->hasMany(Notification::class, 'actor_id');
}
// --------- Relation Helpers ---------
public function addFavourite(Table $table)
{
$this->favouriteTables()->attach($table);
}
public function removeFavourite(Table $table)
{
$this->favouriteTables()->detach($table);
}
public function followDiscussion(Table $table)
{
$this->followedDiscussions()->attach($table);
}
public function unfollowDiscussion(Table $table)
{
$this->followedDiscussions()->detach($table);
}
}