changes
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
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\HasMany;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Laravel\Scout\Searchable;
|
||||
@@ -47,7 +48,8 @@ public function client(): BelongsTo
|
||||
|
||||
public function person(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Person\Person::class);
|
||||
return $this->belongsTo(\App\Models\Person\Person::class)
|
||||
->with(['phones', 'addresses']);
|
||||
}
|
||||
|
||||
public function contracts(): HasMany
|
||||
@@ -59,4 +61,8 @@ public function activities(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\Activity::class);
|
||||
}
|
||||
|
||||
public function segments(): BelongsToMany {
|
||||
return $this->belongsToMany(\App\Models\Segment::class)->withTimestamps();
|
||||
}
|
||||
}
|
||||
|
||||
+13
-9
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,9 +4,15 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Event extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\EventFactory> */
|
||||
use HasFactory;
|
||||
|
||||
public function decisions(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(\App\Models\Decision::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,14 +76,16 @@ public function phones(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\Person\PersonPhone::class)
|
||||
->with(['type'])
|
||||
->where('active','=',1);
|
||||
->where('active','=',1)
|
||||
->orderBy('id');
|
||||
}
|
||||
|
||||
public function addresses(): HasMany
|
||||
{
|
||||
return $this->hasMany(\App\Models\Person\PersonAddress::class)
|
||||
->with(['type'])
|
||||
->where('active','=',1);
|
||||
->where('active','=',1)
|
||||
->orderBy('id');
|
||||
}
|
||||
|
||||
public function group(): BelongsTo
|
||||
|
||||
@@ -14,4 +14,8 @@ class Segment extends Model
|
||||
public function contracts(): BelongsToMany {
|
||||
return $this->belongsToMany(\App\Models\Contract::class);
|
||||
}
|
||||
|
||||
public function clientCase(): BelongsToMany {
|
||||
return $this->belongsToMany(\App\Models\ClientCase::class)->withTimestamps();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user