diff --git a/app/Models/Server.php b/app/Models/Server.php index fb82617d9..0c43ea25b 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -8,7 +8,6 @@ use Illuminate\Notifications\Notifiable; use Illuminate\Database\Query\JoinClause; use Illuminate\Support\Facades\Http; use Psr\Http\Message\ResponseInterface; -use Znck\Eloquent\Traits\BelongsToThrough; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -105,7 +104,6 @@ use App\Exceptions\Http\Server\ServerStateConflictException; */ class Server extends Model { - use BelongsToThrough; use Notifiable; /** diff --git a/app/Models/Task.php b/app/Models/Task.php index c6392b375..591bfcfbb 100644 --- a/app/Models/Task.php +++ b/app/Models/Task.php @@ -3,7 +3,7 @@ namespace App\Models; use Illuminate\Container\Container; -use Znck\Eloquent\Traits\BelongsToThrough; +use Illuminate\Database\Eloquent\Relations\HasOneThrough; use Illuminate\Database\Eloquent\Relations\BelongsTo; use App\Contracts\Extensions\HashidsInterface; @@ -24,8 +24,6 @@ use App\Contracts\Extensions\HashidsInterface; */ class Task extends Model { - use BelongsToThrough; - /** * The resource name for this model when it is transformed into an * API representation using fractal. @@ -117,8 +115,15 @@ class Task extends Model /** * Return the server a task is assigned to, acts as a belongsToThrough. */ - public function server(): \Znck\Eloquent\Relations\BelongsToThrough + public function server(): HasOneThrough { - return $this->belongsToThrough(Server::class, Schedule::class); + return $this->hasOneThrough( + Server::class, + Schedule::class, + 'id', // schedules.id + 'id', // servers.id + 'schedule_id', // tasks.schedule_id + 'server_id' // schedules.server_id + ); } }