Home > Blockchain >  how to get the value in array from database laravel
how to get the value in array from database laravel

Time:07-22

I want to extract the values from array in a column from database. For example, my value in my permission column is ["Create","Edit","Delete]. So when I dd($user->permission) it would return like that. How can I get the value from it so that I can return the result in a list. I have really no idea for now and what I cannot find similar question to mine.

CodePudding user response:

This is a task for mutators. Simply add to your model:

protected $casts = [
    'permission' => 'array',
];
  • Related