50 lines
916 B
PHP
Executable File
50 lines
916 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class PersonaEmailMultipla extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'persone_email_multiple';
|
|
|
|
protected $fillable = [
|
|
'persona_id',
|
|
'email',
|
|
'tipo_email',
|
|
'attiva'
|
|
];
|
|
|
|
protected $casts = [
|
|
'attiva' => 'boolean'
|
|
];
|
|
|
|
/**
|
|
* Relazione con persona
|
|
*/
|
|
public function persona(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Persona::class);
|
|
}
|
|
|
|
/**
|
|
* SCOPE: Email attive
|
|
*/
|
|
public function scopeAttive($query)
|
|
{
|
|
return $query->where('attiva', true);
|
|
}
|
|
|
|
/**
|
|
* SCOPE: Per tipo email
|
|
*/
|
|
public function scopeTipo($query, $tipo)
|
|
{
|
|
return $query->where('tipo_email', $tipo);
|
|
}
|
|
}
|