'int', 'completed' => 'int', 'status' => 'int', 'order_to' => 'bool', 'active' => 'bool', 'default' => 'bool', 'token_active' => 'bool', 'settings' => 'array', 'order' => 'array' ]; protected $dates = [ 'date' ]; protected $hidden = [ 'token' ]; protected $fillable = [ 'auth_user_id', 'date', 'name', 'place', 'description', 'pos', 'completed', 'status', 'order_to', 'active', 'default', 'token', 'token_active', 'settings', 'order' ]; 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 homeparty_order_items(){ return $this->hasMany('App\Models\HomepartyUserOrderItem','homeparty_id'); } 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; } public function getTokenLink(){ return url('homeparty/'.$this->token); } }