58 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| declare(strict_types=1);
 | |
| 
 | |
| namespace App\Models;
 | |
| 
 | |
| use Illuminate\Database\Eloquent\Casts\Attribute;
 | |
| use Illuminate\Database\Eloquent\Factories\HasFactory;
 | |
| use Illuminate\Database\Eloquent\Model;
 | |
| use Illuminate\Database\Eloquent\Relations\HasMany;
 | |
| 
 | |
| /**
 | |
|  * @property int $id
 | |
|  * @property string $token
 | |
|  * @property string $recipient
 | |
|  * @property string $email
 | |
|  * @property string $phoneNumber
 | |
|  * @property array $locations
 | |
|  * @property string|null $mission
 | |
|  * @property string|null $rodo
 | |
|  * @property string|null $position
 | |
|  * @property int $views
 | |
|  */
 | |
| class CV extends Model
 | |
| {
 | |
|     use HasFactory;
 | |
| 
 | |
|     protected $table = 'cvs';
 | |
|     protected $guarded = [];
 | |
|     protected $casts = [
 | |
|         'locations' => 'array',
 | |
|         'views' => 'integer',
 | |
|     ];
 | |
| 
 | |
|     protected function phoneNumber(): Attribute
 | |
|     {
 | |
|         return Attribute::make(
 | |
|             get: fn (mixed $value, array $attributes): ?string => str_replace(' ', '', $attributes['phone_number'] ?? ''),
 | |
|         );
 | |
|     }
 | |
| 
 | |
|     protected function formattedPhoneNumber(): Attribute
 | |
|     {
 | |
|         return Attribute::make(
 | |
|             get: fn (mixed $value, array $attributes): ?string => $attributes['phone_number'] ?? '',
 | |
|         );
 | |
|     }
 | |
| 
 | |
|     public function info(): HasMany
 | |
|     {
 | |
|         return $this->hasMany(CVInfo::class, 'cv_id');
 | |
|     }
 | |
| 
 | |
|     public function getRouteKeyName(): string
 | |
|     {
 | |
|         return 'token';
 | |
|     }
 | |
| } |