LegacyDocument.php
1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
/**
* LegacyCourse
*
* @property string $name Nome do curso
*/
class LegacyDocument extends Model
{
public const CREATED_AT = 'data_cad';
public const UPDATED_AT = null;
/**
* @var string
*/
protected $table = 'cadastro.documento';
/**
* @var string
*/
protected $primaryKey = 'idpes';
/**
* @var array
*/
protected $fillable = [
'idpes',
'rg',
'certidao_nascimento',
'operacao',
'origem_gravacao',
];
/**
* The "booting" method of the model.
*
* @return void
*/
protected static function boot()
{
parent::boot();
static::creating(function ($model) {
$model->origem_gravacao = 'M';
$model->operacao = 'I';
});
}
public function birthRegistration(): Attribute
{
return Attribute::make(
get: function () {
if ($this->tipo_cert_civil === 91) {
$data = collect();
$this->num_termo && $data->push('Termo: ' . $this->num_termo);
$this->num_livro && $data->push('Livro: ' . $this->num_livro);
$this->num_folha && $data->push('Folha: ' . $this->num_folha);
return $data->implode(' ');
}
return $this->certidao_nascimento;
},
);
}
}