Closed elvispdosreis closed 5 years ago
I was able to do the mapping and use in the query because the return fields do not come with the mapping
<?php use Illuminate\Database\Eloquent\Model; use Sofa\Eloquence\Eloquence; use Sofa\Eloquence\Mappable; use Sofa\Eloquence\Mutable; class Product extends Model { use Eloquence; use Mappable, Mutable; protected $table = 'produtos'; protected $mappedOnly = true; protected $primaryKey = 'id_produto'; protected $maps = [ 'id' => 'id_produto', 'produto' => 'name' ]; }
$row = \App\Model\DB\Product::find(471);
result
{ "id_produto": 471, "produto": "HD 320GB SEAGATE SATA 7200RPM 16MB ST3320820SCE" "updated_at": "2019-01-31 19:20:23", "created_at": "2018-09-06 06:50:23" }
has how do I return the mapped fields name id_produto to id and produto to name
I added $ appends and $ visible and resolved
I was able to do the mapping and use in the query because the return fields do not come with the mapping
result
has how do I return the mapped fields name id_produto to id and produto to name