5 months ago

how to get display pluck column from a model function in blade file

Posted 5 months ago by princeoo7

I am stuck with a pretty simple and stupid problem :/

i have a function in model which fetch the name and color code related to status from db called status().


public function status()
        return $this->hasOne(Status::class, 'code', 'status')->pluck('name', 'color');

i am using it in blade like this, as of now to see the result:


output is like this:


if i do,


i get error :

Property [name] does not exist on this collection instance.     

where am i going wrong with pluck as you can see that instead of giving me a name based keyword in result it is only fetching the value of the key.

i hope someone can help me out this is one ...

Please sign in or create an account to participate in this conversation.