3
0
Fork 0
This repository has been archived on 2024-11-14. You can view files and clone it, but cannot push or open issues or pull requests.
ThemeParkPlus-Panel/app/User.php

97 lines
2.4 KiB
PHP
Raw Normal View History

2020-02-26 13:59:58 +00:00
<?php
namespace App;
use App\Cache\Cache;
2021-06-27 19:01:43 +00:00
use Carbon\Carbon;
2020-02-26 13:59:58 +00:00
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable implements MustVerifyEmail
{
use Notifiable;
protected $guard_name = 'web';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'uuid', 'email', 'password', 'google2fa_secret',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token', 'google2fa_secret',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
2021-06-27 19:01:43 +00:00
public function fixedUUID() {
$uuid = substr_replace($this->uuid, '-', 8, 0);
$uuid = substr_replace($uuid, '-', 13, 0);
$uuid = substr_replace($uuid, '-', 18, 0);
return substr_replace($uuid, '-', 23, 0);
}
2020-02-26 13:59:58 +00:00
private $username;
public function username() {
if(!empty($this->username))
return $this->username;
$username = Cache::getUsername($this->uuid);
$this->username = $username;
return $username;
}
private $shows = null;
public function hasShows() {
if($this->shows !== null)
return true;
$shows = Show::join('seats', 'seats.show_id', '=', 'shows.id')
->select([
'shows.title', 'shows.description', 'shows.image', 'seats.*'
])
->where('seats.uuid', '=', $this->uuid)
2021-06-27 19:01:43 +00:00
->where('seats.date', '>', Carbon::now())
->get()->all();
$this->shows = $shows;
return !empty($shows);
}
public function getShows() {
if($this->shows !== null)
return $this->shows;
$shows = Show::join('seats', 'seats.show_id', '=', 'shows.id')
->select([
'shows.title', 'shows.description', 'shows.image', 'seats.*'
])
->where('seats.uuid', '=', $this->uuid)
2021-06-27 19:01:43 +00:00
->where('seats.date', '>', Carbon::now())
->get()->all();
$this->shows = $shows;
return $shows;
}
2020-02-26 13:59:58 +00:00
public function photo() {
return 'https://crafatar.com/avatars/'.$this->uuid.'?overlay';
}
}