1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 05:32:39 +01:00
invoiceninja/app/Models/User.php

75 lines
1.5 KiB
PHP
Raw Normal View History

2018-10-04 19:10:43 +02:00
<?php
namespace App\Models;
2018-10-04 19:10:43 +02:00
use App\Models\Traits\SetsUserSessionAttributes;
use App\Models\Traits\UserTrait;
use App\Utils\Traits\MakesHash;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
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;
use SoftDeletes;
use PresentableTrait;
use MakesHash;
protected $guard = 'user';
protected $dates = ['deleted_at'];
protected $presenter = 'App\Models\Presenters\UserPresenter';
2018-10-04 19:10:43 +02:00
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'first_name',
'last_name',
'email',
'phone',
'signature',
'avatar',
'accepted_terms_version'
2018-10-04 19:10:43 +02:00
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'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
];
public function companies()
{
return $this->belongsToMany(Company::class);
}
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
}