Du kan prova att lägga till ett villkor i dina images()
metod:
<?php
namespace App\Entities;
use Illuminate\Database\Eloquent\Model;
class User extends Model implements Transformable
{
use TransformableTrait;
protected $table = 'users';
protected $primaryKey = 'users_id';
public function images($filtered=false)
{
if ($filtered) {
return $this->hasMany('App\Entities\Image','resource_id')->where('flag','user');
}
return $this->hasMany('App\Entities\Image','resource_id');
}
}
och prova samma logik som din Product
modell