79133271

Date: 2024-10-28 12:00:30
Score: 1
Natty:
Report link

Remove the cast to array

relation as same

public function skills()
{
  return $this->hasMany(Skill::class, 'id', 'skills');
}

used the accessor like this

public function getSkillsAttribute($value)
{
   $skillIds = json_decode($value, true); 
   return Skill::whereIn('id', $skillIds)->get();
}
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Avinash Bansode