1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00
invoiceninja/app/Models/User.php
David Bomba af9ae06289
Model encode primary keys (#2510)
* Client Address

* Vue components for address

* Fix for null objects being passed to Vue

* Copy Billing Address

* route key

* Social auth

* Pad out route bindings

* Deploy hashes across models

* social auth buttons
2018-11-20 15:36:56 +11:00

75 lines
1.5 KiB
PHP

<?php
namespace App\Models;
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;
class User extends Authenticatable implements MustVerifyEmail
{
use Notifiable;
use SoftDeletes;
use PresentableTrait;
use MakesHash;
protected $guard = 'user';
protected $dates = ['deleted_at'];
protected $presenter = 'App\Models\Presenters\UserPresenter';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'first_name',
'last_name',
'email',
'phone',
'signature',
'avatar',
'accepted_terms_version'
];
/**
* 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',
];
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;
}
}