Sindbad~EG File Manager
<?php
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable {
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'user_type', 'status', 'profile_picture', 'two_factor_code', 'two_factor_expires_at',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
'two_factor_expires_at' => 'datetime',
'otp_expires_at' => 'datetime',
];
public function getCreatedAtAttribute($value) {
$date_format = get_date_format();
$time_format = get_time_format();
return \Carbon\Carbon::parse($value)->format("$date_format $time_format");
}
public function role() {
return $this->belongsTo('App\Models\Role', 'role_id')->withDefault();
}
public function member() {
return $this->hasOne('App\Models\Member', 'user_id')->withDefault();
}
public function branch() {
return $this->belongsTo('App\Models\Branch', 'branch_id')->withDefault();
}
public function generateTwoFactorCode() {
$this->timestamps = false;
$this->two_factor_code = rand(100000, 999999);
$this->two_factor_expires_at = now()->addMinutes(30);
$this->two_factor_code_count++;
$this->save();
}
public function resetTwoFactorCode() {
$this->timestamps = false;
$this->two_factor_code = null;
$this->two_factor_expires_at = null;
$this->two_factor_code_count = 0;
$this->save();
}
}
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists