{$server->getKeyName()} = $client->generateId($size = 21); }); static::deleting(function(Server $server) { Pterodactyl::client()->delete("/application/servers/{$server->pterodactyl_id}"); }); } /** * @return bool */ public function isSuspended(){ return !is_null($this->suspended); } /** * @return PromiseInterface|Response */ public function getPterodactylServer(){ return Pterodactyl::client()->get("/application/servers/{$this->pterodactyl_id}"); } /** * * @throws Exception */ public function suspend(){ $response = Pterodactyl::suspendServer($this); if ($response->successful()) { $this->update([ 'suspended' => now() ]); } return $this; } /** * @throws Exception */ public function unSuspend() { $response = Pterodactyl::unSuspendServer($this); if ($response->successful()) { $this->update([ 'suspended' => null ]); } return $this; } /** * @return HasOne */ public function product(){ return $this->hasOne(Product::class , 'id' , 'product_id'); } /** * @return HasOne */ public function nest(){ return $this->hasOne(Nest::class , 'id' , 'nest_id'); } /** * @return HasOne */ public function egg(){ return $this->hasOne(Egg::class , 'id' , 'egg_id'); } /** * @return HasOne */ public function location(){ return $this->hasOne(Location::class , 'id' , 'location_id'); } /** * @return BelongsTo */ public function user(){ return $this->belongsTo(User::class , 'user_id' , 'id'); } }