- 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.
56 lines
1.2 KiB
PHP
56 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Carbon\Carbon;
|
|
|
|
class LeadDetail extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'client_id',
|
|
'contact_date',
|
|
'contract_end_date',
|
|
'contract_type',
|
|
'delivery_point_code'
|
|
];
|
|
|
|
public function client()
|
|
{
|
|
return $this->belongsTo(Clients::class);
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Accessor - quando for buscar do BD converte para d/m/Y
|
|
*/
|
|
public function getContactDateAttribute($value)
|
|
{
|
|
return $value ? Carbon::parse($value)->format('d/m/Y') : null;
|
|
}
|
|
|
|
public function getContractEndDateAttribute($value)
|
|
{
|
|
return $value ? Carbon::parse($value)->format('d/m/Y') : null;
|
|
}
|
|
|
|
|
|
public function setContactDateAttribute($value)
|
|
{
|
|
$this->attributes['contact_date'] = $value
|
|
? Carbon::createFromFormat('d/m/Y', $value)->format('Y-m-d')
|
|
: null;
|
|
}
|
|
|
|
public function setContractEndDateAttribute($value)
|
|
{
|
|
$this->attributes['contract_end_date'] = $value
|
|
? Carbon::createFromFormat('d/m/Y', $value)->format('Y-m-d')
|
|
: null;
|
|
}
|
|
}
|