2018-10-04 19:10:43 +02:00
|
|
|
<?php
|
|
|
|
|
2018-10-12 13:29:34 +02:00
|
|
|
namespace App\Models;
|
2018-10-04 19:10:43 +02:00
|
|
|
|
2018-11-02 11:54:46 +01:00
|
|
|
use App\Models\Traits\SetsUserSessionAttributes;
|
2018-10-21 00:26:21 +02:00
|
|
|
use App\Models\Traits\UserTrait;
|
2018-11-20 05:36:56 +01:00
|
|
|
use App\Utils\Traits\MakesHash;
|
2018-10-15 07:00:48 +02:00
|
|
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
2018-11-20 05:36:56 +01:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2018-10-15 07:00:48 +02:00
|
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
2018-11-20 05:36:56 +01:00
|
|
|
use Illuminate\Notifications\Notifiable;
|
2018-10-22 14:04:37 +02:00
|
|
|
use Laracasts\Presenter\PresentableTrait;
|
2018-10-04 19:10:43 +02:00
|
|
|
|
2018-10-24 05:50:15 +02:00
|
|
|
class User extends Authenticatable implements MustVerifyEmail
|
2018-10-04 19:10:43 +02:00
|
|
|
{
|
|
|
|
use Notifiable;
|
2018-10-15 14:40:34 +02:00
|
|
|
use SoftDeletes;
|
2018-10-22 14:04:37 +02:00
|
|
|
use PresentableTrait;
|
2018-11-20 05:36:56 +01:00
|
|
|
use MakesHash;
|
|
|
|
|
2018-10-15 07:00:48 +02:00
|
|
|
protected $guard = 'user';
|
2018-10-19 05:45:55 +02:00
|
|
|
|
|
|
|
protected $dates = ['deleted_at'];
|
|
|
|
|
2018-10-22 14:04:37 +02:00
|
|
|
protected $presenter = 'App\Models\Presenters\UserPresenter';
|
|
|
|
|
2018-10-04 19:10:43 +02:00
|
|
|
/**
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $fillable = [
|
2018-10-15 14:40:34 +02:00
|
|
|
'first_name',
|
|
|
|
'last_name',
|
|
|
|
'email',
|
|
|
|
'phone',
|
|
|
|
'signature',
|
|
|
|
'avatar',
|
2018-10-19 05:45:55 +02:00
|
|
|
'accepted_terms_version'
|
2018-10-04 19:10:43 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The attributes that should be hidden for arrays.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $hidden = [
|
2018-10-15 14:40:34 +02:00
|
|
|
'remember_token',
|
|
|
|
'oauth_user_id',
|
|
|
|
'oauth_provider_id',
|
|
|
|
'google_2fa_secret',
|
|
|
|
'google_2fa_phone',
|
|
|
|
'remember_2fa_token',
|
|
|
|
'slack_webhook_url',
|
2018-10-04 19:10:43 +02:00
|
|
|
];
|
2018-10-15 14:40:34 +02:00
|
|
|
|
2018-10-29 04:16:17 +01:00
|
|
|
|
2018-11-02 11:54:46 +01:00
|
|
|
|
|
|
|
public function companies()
|
2018-10-29 04:16:17 +01:00
|
|
|
{
|
2018-11-02 11:54:46 +01:00
|
|
|
return $this->belongsToMany(Company::class);
|
2018-10-15 14:40:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function contacts()
|
|
|
|
{
|
|
|
|
return $this->hasMany(Contact::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function owns($entity)
|
|
|
|
{
|
|
|
|
return ! empty($entity->user_id) && $entity->user_id == $this->id;
|
|
|
|
}
|
2018-10-04 19:10:43 +02:00
|
|
|
}
|