- Created ExampleTest and RoutesTest for basic application response and route testing. - Implemented IsolatedDatabaseTestCase for isolated database testing. - Added unit tests for various models and services including Contract, CPE, and LeadDetail. - Developed request validation tests for CreateClientRequest, UpdateClientRequest, and ContractRequest. - Introduced Vite configuration for asset management in the Laravel application.
72 lines
1.4 KiB
PHP
72 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class Clients extends Model
|
|
{
|
|
protected $fillable = [
|
|
'name',
|
|
'tax_number',
|
|
'address',
|
|
'phone',
|
|
'email',
|
|
'seller_id',
|
|
'receive_invoice_id',
|
|
'client_type_id',
|
|
'contact_info',
|
|
'notes',
|
|
'type',
|
|
'lead_status_id',
|
|
'locality'
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be hidden for serialization.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
protected $hidden = [
|
|
];
|
|
|
|
|
|
public function contracts()
|
|
{
|
|
return $this->hasMany(Contract::class, 'client_id');
|
|
}
|
|
|
|
|
|
public function seller(): BelongsTo {
|
|
return $this->belongsTo(User::class, 'seller_id');
|
|
}
|
|
|
|
public function cpes()
|
|
{
|
|
return $this->hasMany(Cpe::class);
|
|
}
|
|
|
|
public function hasUnpaidCpes()
|
|
{
|
|
return $this->cpes->contains(function ($cpe) {
|
|
return !$cpe->isPaid();
|
|
});
|
|
}
|
|
|
|
public function clientType()
|
|
{
|
|
return $this->belongsTo(ClientType::class, 'client_type_id');
|
|
}
|
|
|
|
public function leadStatus()
|
|
{
|
|
return $this->belongsTo(LeadStatus::class, 'lead_status_id');
|
|
}
|
|
|
|
public function leadDetail()
|
|
{
|
|
return $this->hasOne(LeadDetail::class, 'client_id', 'id');
|
|
}
|
|
}
|