1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* rmarchiv.tk |
5
|
|
|
* (c) 2016-2017 by Marcel 'ryg' Hering |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace App\Models; |
9
|
|
|
|
10
|
|
|
use GeneaLabs\LaravelModelCaching\Traits\Cachable; |
11
|
|
|
use Illuminate\Database\Eloquent\Model; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class Logo. |
15
|
|
|
* |
16
|
|
|
* @property int $id |
17
|
|
|
* @property string $title |
18
|
|
|
* @property string $extension |
19
|
|
|
* @property string $filename |
20
|
|
|
* @property int $user_id |
21
|
|
|
* @property string $deleted_at |
22
|
|
|
* @property \Carbon\Carbon $created_at |
23
|
|
|
* @property \Carbon\Carbon $updated_at |
24
|
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\Logo whereId($value) |
25
|
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\Logo whereTitle($value) |
26
|
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\Logo whereExtension($value) |
27
|
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\Logo whereFilename($value) |
28
|
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\Logo whereUserId($value) |
29
|
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\Logo whereDeletedAt($value) |
30
|
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\Logo whereCreatedAt($value) |
31
|
|
|
* @method static \Illuminate\Database\Query\Builder|\App\Models\Logo whereUpdatedAt($value) |
32
|
|
|
* @mixin \Eloquent |
33
|
|
|
* @property-read \App\Models\User $user |
34
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\LogoVote[] $logovote |
35
|
|
|
* @property-read int $voteresult |
36
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\Venturecraft\Revisionable\Revision[] $revisionHistory |
37
|
|
|
*/ |
38
|
|
|
class Logo extends Model |
39
|
|
|
{ |
40
|
|
|
use \Venturecraft\Revisionable\RevisionableTrait; |
41
|
|
|
protected $table = 'logos'; |
42
|
|
|
|
43
|
|
|
public $timestamps = true; |
44
|
|
|
|
45
|
|
|
protected $fillable = [ |
46
|
|
|
'title', |
47
|
|
|
'extension', |
48
|
|
|
'filename', |
49
|
|
|
'user_id', |
50
|
|
|
]; |
51
|
|
|
|
52
|
|
|
protected $guarded = []; |
53
|
|
|
|
54
|
|
|
public function user() |
55
|
|
|
{ |
56
|
|
|
return $this->belongsTo('App\Models\User'); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function logovote() |
60
|
|
|
{ |
61
|
|
|
return $this->belongsToMany('App\Models\LogoVote'); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function voteresult() |
|
|
|
|
65
|
|
|
{ |
66
|
|
|
$up = LogoVote::whereLogoId($this->id)->selectRaw('SUM(up) as sumup, SUM(down) as sumdown'); |
67
|
|
|
|
68
|
|
|
$res = $up->get(['sumup', 'sumdown']); |
69
|
|
|
|
70
|
|
|
return $res; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@return
annotation as described here.