File manager - Edit - /var/www/html/gop/api/app/Models/Medicao.php
Back
<?php namespace App\Models; use Illuminate\Database\Eloquent\Casts\Attribute; class Medicao extends BaseModel { protected $table = 'medicoes'; protected $fillable = [ 'identificador', 'unidade', 'quantidade', 'fase_servico_subitem_id', 'prestador_id', 'fiscalizacao_id', ]; protected $appends = [ 'anexos', 'valor_medido', ]; protected function anexos(): Attribute { $images = $this->images; $anexos = [ 'images' => $images, ]; return new Attribute( get: fn () => $anexos, ); } protected function valorMedido(): Attribute { $preco = $this->subitem?->preco_unitario ?: 0; return new Attribute( get: fn () => $preco * $this->quantidade, ); } public function subitem() { return $this->belongsTo(FaseServicoSubitem::class, 'fase_servico_subitem_id'); } public function prestador() { return $this->belongsTo(Prestador::class); } public function images() { return $this->morphMany(Image::class, 'imageable'); } public function fiscalizacao() { return $this->belongsTo(Fiscalizacao::class); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings