-
Notifications
You must be signed in to change notification settings - Fork 53
/
Competitor.php
52 lines (45 loc) · 1.03 KB
/
Competitor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace Xoco70\LaravelTournaments\Models;
class Competitor extends Fighter
{
protected $DATES = ['created_at', 'updated_at'];
protected $table = 'competitor';
public $timestamps = true;
protected $fillable = [
'tournament_category_id',
'user_id',
'confirmed',
];
/**
* Get User from Competitor.
*
* @return mixed
*/
public function user()
{
return $this->belongsTo(config('laravel-tournaments.user.model'));
}
/**
* @return null|string
*/
public function getNameAttribute()
{
return $this->defaultName() ?? $this->user->name;
}
/**
* @return null|string
*/
public function getFullName() //TODO Should remove get prefix
{
return $this->defaultName() ?? $this->user->firstname.' '.$this->user->lastname;
}
/**
* @return null|string
*/
private function defaultName()
{
if ($this == null || $this->user == null) {
return '';
}
}
}