This commit is contained in:
Simon Pocrnjič
2025-01-02 18:38:47 +01:00
parent 0c3bbfe18f
commit 0f8cfd3f16
41 changed files with 2013 additions and 591 deletions
+13 -9
View File
@@ -3,10 +3,15 @@
namespace App\Models;
use App\Traits\Uuid;
use Illuminate\Database\Eloquent\Factories\BelongsToManyRelationship;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Relations\HasOneOrManyThrough;
use Illuminate\Database\Eloquent\Relations\MorphOne;
use Illuminate\Database\Eloquent\SoftDeletes;
class Contract extends Model
@@ -36,17 +41,16 @@ public function type(): BelongsTo
return $this->belongsTo(\App\Models\ContractType::class, 'type_id');
}
public function client(): BelongsTo
public function clientCase(): BelongsTo
{
return $this->belongsTo(\App\Models\Person\Person::class, 'client_id');
return $this->belongsTo(\App\Models\ClientCase::class)
->with(['person']);
}
public function debtor(): BelongsTo
{
return $this->belongsTo(\App\Models\Person\Person::class, 'debtor_id');
}
public function segments(): BelongsToMany {
return $this->belongsToMany(\App\Models\Segment::class);
return $this->belongsToMany(\App\Models\Segment::class)
->withPivot('active', 'created_at')
->wherePivot('active', true);
}
}