Reputation: 581
This is my model:
class Positions extends Model implements Repository
{
protected $fillable = ['index_id', 'title', 'description'];
public function index()
{
return $this->belongsTo('TEST\Indices', 'index_id');
}
public function getById($id)
{
return $this->with('index')->find($id);
}
}
how to use pluck()
in getById()
function for listing index relationship?
Upvotes: 0
Views: 218
Reputation: 11083
You can do it like this :
return $this->with('index')->find($id)->pluck('index.indexField');
Upvotes: 0