mirror of
https://repo.getmonero.org/AnonDev/xmrmemes.git
synced 2025-07-22 14:30:54 -04:00
Initial Commit
This commit is contained in:
commit
cc2af611e1
148 changed files with 54234 additions and 0 deletions
67
app/Models/User.php
Normal file
67
app/Models/User.php
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
protected $appends = ['tips_total', 'memes_total'];
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'address',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* 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',
|
||||
];
|
||||
|
||||
public function memes()
|
||||
{
|
||||
return $this->hasMany(Meme::class)->orderByDesc('created_at');
|
||||
}
|
||||
|
||||
public function tips()
|
||||
{
|
||||
return $this->hasManyThrough(Tip::class, Meme::class, 'id', 'address_id');
|
||||
}
|
||||
|
||||
public function getMemesTotalAttribute()
|
||||
{
|
||||
return $this->memes->count();
|
||||
}
|
||||
|
||||
public function getTipsTotalAttribute()
|
||||
{
|
||||
return $this->tips->sum('amount_formatted');
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue