Add new version in repository
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Core\App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -7,17 +6,18 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Application extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
protected $connection = 'system';
|
||||
protected $guarded = ['id'];
|
||||
public $timestamps = false;
|
||||
|
||||
public function pages()
|
||||
{
|
||||
return $this->hasMany('App\Models\Core\App\ApplicationPage');
|
||||
return $this->hasMany(\App\Models\Core\App\ApplicationPage::class);
|
||||
}
|
||||
|
||||
public function modules()
|
||||
{
|
||||
return $this->hasMany('App\Models\Core\App\ApplicationModule');
|
||||
return $this->hasMany(\App\Models\Core\App\ApplicationModule::class);
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
|
||||
47
app/Models/Core/App/ApplicationClient.php
Normal file
47
app/Models/Core/App/ApplicationClient.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
namespace App\Models\Core\App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ApplicationClient extends Model
|
||||
{
|
||||
protected $connection = 'system';
|
||||
protected $guarded = [];
|
||||
protected $table = 'application_clients';
|
||||
public $timestamps = false;
|
||||
|
||||
public function application()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Core\App\Application::class);
|
||||
}
|
||||
|
||||
public function client()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Partner\Client');
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->where('active', 1);
|
||||
}
|
||||
|
||||
public function scopeByApplication($query, $id)
|
||||
{
|
||||
return $query->where('application_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByClient($query, $id)
|
||||
{
|
||||
return $query->where('client_id', $id);
|
||||
}
|
||||
|
||||
public function scopeBySlug($query, $slug)
|
||||
{
|
||||
return $query->whereHas(
|
||||
'application', function ($query) use ($slug) {
|
||||
$query->bySlug($slug);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Core\App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -9,16 +8,17 @@ class ApplicationModule extends Model
|
||||
{
|
||||
protected $connection = 'system';
|
||||
protected $table = 'application_modules';
|
||||
protected $guarded = ['id'];
|
||||
public $timestamps = false;
|
||||
|
||||
public function application()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Core\App\Application');
|
||||
return $this->belongsTo(\App\Models\Core\App\Application::class);
|
||||
}
|
||||
|
||||
public function permissions()
|
||||
{
|
||||
return $this->hasMany('App\Auth\Permission');
|
||||
return $this->hasMany(\App\Models\Core\Auth\Permission::class);
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Application;
|
||||
namespace App\Models\Core\App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ApplicationPage extends Model
|
||||
{
|
||||
protected $connection = 'system';
|
||||
protected $table = 'application_pages';
|
||||
public $timestamps = false;
|
||||
|
||||
public function application()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Core\App');
|
||||
return $this->belongsTo(\App\Models\Core\App\Application::class);
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
|
||||
20
app/Models/Core/Auth/PasswordReset.php
Normal file
20
app/Models/Core/Auth/PasswordReset.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PasswordReset extends Model
|
||||
{
|
||||
protected $table = 'password_resets';
|
||||
|
||||
public function scopeByToken($query, $token)
|
||||
{
|
||||
return $query->where('token', $token);
|
||||
}
|
||||
|
||||
public function scopeByEmail($query, $email)
|
||||
{
|
||||
return $query->where('email', $email);
|
||||
}
|
||||
}
|
||||
23
app/Models/Core/Auth/PasswordSecurity.php
Normal file
23
app/Models/Core/Auth/PasswordSecurity.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PasswordSecurity extends Model
|
||||
{
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'user_id', 'password_expiry_days', 'password_updated_at'
|
||||
];
|
||||
|
||||
// set relation
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Core\Auth\User');
|
||||
}
|
||||
}
|
||||
@@ -2,48 +2,20 @@
|
||||
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Laratrust\Models\LaratrustPermission;
|
||||
use Sebastienheyd\Boilerplate\Models\Permission as parentPermission;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $display_name
|
||||
* @property string $description
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Role[] $roles
|
||||
*
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Permission whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Permission whereDescription($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Permission whereDisplayName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Permission whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Permission whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Permission whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
|
||||
class Permission extends LaratrustPermission
|
||||
class Permission extends parentPermission
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function application()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Core\App\Application');
|
||||
return $this->belongsTo(\App\Models\Core\App\Application::class)->withDefault(['name' => '']);
|
||||
}
|
||||
|
||||
public function application_module()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Core\App\ApplicationModule');
|
||||
}
|
||||
|
||||
public function getDisplayNameAttribute($value)
|
||||
{
|
||||
return __($value);
|
||||
}
|
||||
|
||||
public function getDescriptionAttribute($value)
|
||||
{
|
||||
return __($value);
|
||||
return $this->belongsTo(\App\Models\Core\App\ApplicationModule::class)->withDefault(['name' => '']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,34 +2,8 @@
|
||||
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $display_name
|
||||
* @property string $description
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Role[] $roles
|
||||
*
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Permission whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Permission whereDescription($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Permission whereDisplayName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Permission whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Permission whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Permission whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class PermissionCategory extends Models
|
||||
{
|
||||
public function getDisplayNameAttribute($value)
|
||||
{
|
||||
return __($value);
|
||||
}
|
||||
use Sebastienheyd\Boilerplate\Models\permissionCategory as parentPermissionCategory;
|
||||
|
||||
public function getDescriptionAttribute($value)
|
||||
{
|
||||
return __($value);
|
||||
}
|
||||
class PermissionCategory extends parentPermissionCategory
|
||||
{
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ class PermissionRole extends Model
|
||||
|
||||
public function permission()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Core\Auth\Permission');
|
||||
return $this->belongsTo(\App\Models\Core\Auth\Permission::class);
|
||||
}
|
||||
|
||||
public function role()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Core\Auth\Role');
|
||||
return $this->belongsTo(\App\Models\Core\Auth\Role::class);
|
||||
}
|
||||
|
||||
public function scopeByPermission($query, $id)
|
||||
|
||||
@@ -10,17 +10,17 @@ class PermissionUser extends Model
|
||||
|
||||
public function permission()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Core\Auth\Permission');
|
||||
return $this->belongsTo(\App\Models\Core\Auth\Permission::class);
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Core\Auth\User');
|
||||
return $this->belongsTo(\App\Models\Core\Auth\User::class);
|
||||
}
|
||||
|
||||
public function team()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Core\Auth\Team');
|
||||
return $this->belongsTo(\App\Models\Core\Auth\Team::class);
|
||||
}
|
||||
|
||||
public function scopeByUser($query, $id)
|
||||
|
||||
@@ -2,44 +2,9 @@
|
||||
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Laratrust\Models\LaratrustRole;
|
||||
use Sebastienheyd\Boilerplate\Models\Role as parentRole;
|
||||
|
||||
/**
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $display_name
|
||||
* @property string $description
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Permission[] $permissions
|
||||
*
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Role whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Role whereDescription($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Role whereDisplayName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Role whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Role whereName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Role whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
|
||||
class Role extends LaratrustRole
|
||||
class Role extends parentRole
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function getDisplayNameAttribute($value)
|
||||
{
|
||||
return __($value);
|
||||
}
|
||||
|
||||
public function getDescriptionAttribute($value)
|
||||
{
|
||||
return __($value);
|
||||
}
|
||||
|
||||
public function getNbUsers()
|
||||
{
|
||||
return User::whereRoleIs($this->name)->count();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -11,12 +10,12 @@ class RoleUser extends Model
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Core\Auth\User');
|
||||
return $this->belongsTo(\App\Models\Core\Auth\User::class);
|
||||
}
|
||||
|
||||
public function team()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Core\Auth\Team');
|
||||
return $this->belongsTo(\App\Models\Core\Auth\Team::class);
|
||||
}
|
||||
|
||||
public function scopeByUser($query, $id)
|
||||
|
||||
@@ -15,12 +15,11 @@ class Team extends LaratrustTeam
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->hasMany('App\Models\Core\Auth\User');
|
||||
return $this->hasMany(\App\Models\Core\Auth\User::class);
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->where('active', 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,12 +11,12 @@ class TeamUser extends Model
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Core\Auth\User');
|
||||
return $this->belongsTo(\App\Models\Core\Auth\User::class);
|
||||
}
|
||||
|
||||
public function team()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Core\Auth\Team');
|
||||
return $this->belongsTo(\App\Models\Core\Auth\Team::class);
|
||||
}
|
||||
|
||||
public function scopeByUser($query, $id)
|
||||
|
||||
@@ -5,65 +5,21 @@ namespace App\Models\Core\Auth;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Yadahan\AuthenticationLog\AuthenticationLogable;
|
||||
use Laratrust\Traits\LaratrustUserTrait;
|
||||
use Mpociot\Teamwork\Traits\UserHasTeams;
|
||||
use Sebastienheyd\Boilerplate\Notifications\NewUser as NewUserNotification;
|
||||
use Sebastienheyd\Boilerplate\Notifications\ResetPassword as ResetPasswordNotification;
|
||||
use HighIdeas\UsersOnline\Traits\UsersOnlineTrait;
|
||||
use Sebastienheyd\Boilerplate\Models\User as parentUser;
|
||||
|
||||
/**
|
||||
* Sebastienheyd\Boilerplate\Models\User.
|
||||
*
|
||||
* @property int $id
|
||||
* @property bool $active
|
||||
* @property string $first_name
|
||||
* @property string $last_name
|
||||
* @property string $email
|
||||
* @property string $password
|
||||
* @property string $remember_token
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property string $deleted_at
|
||||
* @property string $last_login
|
||||
* @property-read string|false $avatar_path
|
||||
* @property-read string $avatar_url
|
||||
* @property-read mixed $name
|
||||
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection|\Illuminate\Notifications\DatabaseNotification[] $notifications
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Sebastienheyd\Boilerplate\Models\Permission[] $permissions
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\Sebastienheyd\Boilerplate\Models\Role[] $roles
|
||||
*
|
||||
* @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereActive($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereEmail($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereFirstName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereLastLogin($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereLastName($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User wherePassword($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereRememberToken($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereRoleIs($role = '')
|
||||
* @method static \Illuminate\Database\Query\Builder|\Sebastienheyd\Boilerplate\Models\User whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
|
||||
|
||||
class User extends Authenticatable
|
||||
class User extends parentUser
|
||||
{
|
||||
use Notifiable;
|
||||
use LaratrustUserTrait;
|
||||
use SoftDeletes;
|
||||
use UserHasTeams;
|
||||
use AuthenticationLogable;
|
||||
|
||||
// use UserHasTeams;
|
||||
use AuthenticationLogable, SoftDeletes, UsersOnlineTrait;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['active', 'last_name', 'first_name', 'email', 'password', 'remember_token', 'last_login'];
|
||||
protected $fillable = ['active', 'last_name', 'first_name', 'username', 'email', 'password', 'remember_token', 'last_login'];
|
||||
|
||||
protected $hidden = ['password', 'remember_token'];
|
||||
|
||||
@@ -77,16 +33,23 @@ class User extends Authenticatable
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function passwordSecurity()
|
||||
{
|
||||
return $this->hasOne('App\Models\Core\Auth\PasswordSecurity');
|
||||
}
|
||||
|
||||
public function teams()
|
||||
{
|
||||
return $this->hasManyThrough('App\Models\Core\Auth\Team', 'App\Models\Core\Auth\TeamUser', 'user_id', 'id', 'id', 'team_id');
|
||||
return $this->hasManyThrough(\App\Models\Core\Auth\Team::class, \App\Models\Core\Auth\TeamUser::class, 'user_id', 'id', 'id', 'team_id');
|
||||
}
|
||||
|
||||
public function scopeByTeam($query, $id)
|
||||
{
|
||||
return $query->whereHas('teams', function ($query) use ($id) {
|
||||
$query->where('id', $id);
|
||||
});
|
||||
return $query->whereHas(
|
||||
'teams', function ($query) use ($id) {
|
||||
$query->where('id', $id);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function scopeByUniqueTeam($query)
|
||||
@@ -98,128 +61,4 @@ class User extends Authenticatable
|
||||
{
|
||||
return $query->where('active', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the password reset notification.
|
||||
*
|
||||
* @param string $token
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function sendPasswordResetNotification($token)
|
||||
{
|
||||
$this->notify(new ResetPasswordNotification($token));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send notification when a new user is created.
|
||||
*
|
||||
* @param string $token
|
||||
*/
|
||||
public function sendNewUserNotification($token)
|
||||
{
|
||||
$this->notify(new NewUserNotification($token, $this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return last name in uppercase by default.
|
||||
*
|
||||
* @param $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLastNameAttribute($value)
|
||||
{
|
||||
return mb_strtoupper($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return first name with first char of every word in uppercase.
|
||||
*
|
||||
* @param $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFirstNameAttribute($value)
|
||||
{
|
||||
return mb_convert_case($value, MB_CASE_TITLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a concatenation of first name and last_name if field name does not exists.
|
||||
*
|
||||
* @param $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNameAttribute($value)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
return $this->first_name.' '.$this->last_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return last login date formatted.
|
||||
*
|
||||
* @param string $format
|
||||
* @param string $default
|
||||
*
|
||||
* @return mixed|string
|
||||
*/
|
||||
public function getLastLogin($format = 'YYYY-MM-DD HH:mm:ss', $default = '')
|
||||
{
|
||||
if ($this->last_login === null) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
return Carbon::createFromTimeString($this->last_login)->isoFormat($format);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return role list as a string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRolesList()
|
||||
{
|
||||
$res = [];
|
||||
foreach ($this->roles as $role) {
|
||||
$res[] = __($role->display_name);
|
||||
}
|
||||
if (empty($res)) {
|
||||
return '-';
|
||||
}
|
||||
|
||||
return implode(', ', $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if current user has an avatar.
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
public function getAvatarPathAttribute()
|
||||
{
|
||||
return public_path('images/avatars/'.md5($this->id.$this->email).'.jpg');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return current user avatar uri.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAvatarUrlAttribute()
|
||||
{
|
||||
if (is_file($this->avatar_path)) {
|
||||
$ts = filemtime($this->avatar_path);
|
||||
|
||||
return asset('images/avatars/'.md5($this->id.$this->email).'.jpg?t='.$ts);
|
||||
}
|
||||
|
||||
return asset('/assets/vendor/boilerplate/images/default-user.png');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
33
app/Models/Core/Auth/UserClient.php
Normal file
33
app/Models/Core/Auth/UserClient.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class UserClient extends Model
|
||||
{
|
||||
protected $connection = 'system';
|
||||
protected $guarded = [];
|
||||
public $timestamps = false;
|
||||
|
||||
public function client()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Partner\Client');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo('App\Models\User');
|
||||
}
|
||||
|
||||
public function scopeByClient($query, $id)
|
||||
{
|
||||
return $query->where('client_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByUser($query, $id)
|
||||
{
|
||||
return $query->where('user_id', $id);
|
||||
}
|
||||
}
|
||||
32
app/Models/Core/Auth/UserStatus.php
Normal file
32
app/Models/Core/Auth/UserStatus.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserStatus extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
protected $guarded = [];
|
||||
protected $table = "user_statuses";
|
||||
public $timestamps = false;
|
||||
|
||||
public function scopeByName($query, $name)
|
||||
{
|
||||
return $query->where('name', $name);
|
||||
}
|
||||
|
||||
public function scopeByTranslated($query, $translated)
|
||||
{
|
||||
return $query->where('translated', $translated);
|
||||
}
|
||||
|
||||
public function scopeByNegociator($query)
|
||||
{
|
||||
return $query->where('negociator', '>', 0);
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->where('active', 1);
|
||||
}
|
||||
}
|
||||
32
app/Models/Core/Auth/UserStatusTeam.php
Normal file
32
app/Models/Core/Auth/UserStatusTeam.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace App\Models\Core\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserStatusTeam extends Model
|
||||
{
|
||||
protected $connection = 'mysql';
|
||||
protected $guarded = [];
|
||||
protected $table = "user_status_teams";
|
||||
public $timestamps = false;
|
||||
|
||||
public function user_status()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Core\Auth\UserStatus::class);
|
||||
}
|
||||
|
||||
public function team()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Core\Auth\Team::class);
|
||||
}
|
||||
|
||||
public function scopeByUserStatus($query, $id)
|
||||
{
|
||||
return $query->where('user_status_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByTeam($query, $id)
|
||||
{
|
||||
return $query->where('team_id', $id);
|
||||
}
|
||||
}
|
||||
@@ -8,5 +8,4 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
class Media extends Model
|
||||
{
|
||||
protected $table = 'media';
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user