|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
use AdamWathan\EloquentOAuth\OAuthIdentity;
|
|
|
|
use Illuminate\Notifications\Notifiable;
|
|
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A user in the application
|
|
|
|
*/
|
|
|
|
class User extends Authenticatable
|
|
|
|
{
|
|
|
|
use Notifiable;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $fillable = [
|
|
|
|
'name', 'email', 'password',
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The attributes that should be hidden for arrays.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $hidden = [
|
|
|
|
'password', 'remember_token',
|
|
|
|
];
|
|
|
|
|
|
|
|
/** Owned tables */
|
|
|
|
public function dataTables()
|
|
|
|
{
|
|
|
|
return $this->hasMany(DataTable::class, 'owner_id');
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Assigned OAuth identities */
|
|
|
|
public function socialIdentities()
|
|
|
|
{
|
|
|
|
return $this->hasMany(OAuthIdentity::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Assigned OAuth identities */
|
|
|
|
public function changesets()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Changeset::class, 'author_id');
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Authored comments */
|
|
|
|
public function tableComments()
|
|
|
|
{
|
|
|
|
return $this->hasMany(TableComment::class, 'author_id');
|
|
|
|
}
|
|
|
|
|
|
|
|
/** User's favourite tables (personal collection) */
|
|
|
|
public function favouriteTables()
|
|
|
|
{
|
|
|
|
return $this->belongsToMany(DataTable::class, 'table_favourites');
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Tables whose discussions user follows (this is similar to favourites) */
|
|
|
|
public function followedDiscussions()
|
|
|
|
{
|
|
|
|
return $this->belongsToMany(DataTable::class, 'discussion_follows');
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Reports sent by this user */
|
|
|
|
public function authoredReports()
|
|
|
|
{
|
|
|
|
return $this->hasMany(ContentReport::class, 'author_id');
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Reports of this user */
|
|
|
|
public function reportsOf()
|
|
|
|
{
|
|
|
|
return $this->morphMany(ContentReport::class, 'object');
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Notifications for this user */
|
|
|
|
public function notifications()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Notification::class);
|
|
|
|
}
|
|
|
|
}
|