+ Homparty Part 1
This commit is contained in:
parent
74923859d1
commit
9252094a04
43 changed files with 2385 additions and 66 deletions
120
app/Models/Homeparty.php
Normal file
120
app/Models/Homeparty.php
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Homeparty
|
||||
*
|
||||
* @property int $id
|
||||
* @property Carbon $date
|
||||
* @property string $name
|
||||
* @property string $place
|
||||
* @property string $description
|
||||
* @property int $pos
|
||||
* @property int $completed
|
||||
* @property int $status
|
||||
* @property bool $order_to
|
||||
* @property bool $active
|
||||
* @property bool $default
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property Collection|User[] $users
|
||||
* @package App\Models
|
||||
* @property int|null $auth_user_id
|
||||
* @property-read \App\User|null $auth_user
|
||||
* @property-read \App\Models\HomepartyUser|null $homeparty_host
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\HomepartyUser[] $homeparty_users
|
||||
* @property-read int|null $homeparty_users_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereAuthUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereCompleted($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereDate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereDefault($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereDescription($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereOrderTo($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty wherePlace($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Homeparty extends Model
|
||||
{
|
||||
protected $table = 'homeparties';
|
||||
|
||||
protected $casts = [
|
||||
'pos' => 'int',
|
||||
'completed' => 'int',
|
||||
'status' => 'int',
|
||||
'order_to' => 'bool',
|
||||
'active' => 'bool',
|
||||
'default' => 'bool'
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
'date'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'auth_user_id',
|
||||
'date',
|
||||
'name',
|
||||
'place',
|
||||
'description',
|
||||
'pos',
|
||||
'completed',
|
||||
'status',
|
||||
'order_to',
|
||||
'active',
|
||||
'default'
|
||||
];
|
||||
|
||||
public function auth_user()
|
||||
{
|
||||
return $this->belongsTo('App\User', 'auth_user_id');
|
||||
}
|
||||
|
||||
public function homeparty_users()
|
||||
{
|
||||
return $this->hasMany('App\Models\HomepartyUser', 'homeparty_id');
|
||||
}
|
||||
|
||||
public function homeparty_host()
|
||||
{
|
||||
return $this->hasOne('App\Models\HomepartyUser', 'homeparty_id')->where('is_host', true);
|
||||
}
|
||||
|
||||
public function homeparty_guests()
|
||||
{
|
||||
return $this->hasMany('App\Models\HomepartyUser', 'homeparty_id')->where('is_host', false);
|
||||
}
|
||||
|
||||
|
||||
public function getDateAttribute($value)
|
||||
{
|
||||
if (!$value) {
|
||||
return "";
|
||||
}
|
||||
return Carbon::parse($value)->format(\Util::formatDateDB());
|
||||
}
|
||||
|
||||
public function setDateAttribute($value)
|
||||
{
|
||||
$this->attributes['date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue