lundi 23 août 2021

Laravel - Displaying json from database to view

I have a column in my database that stores json data as ["Item_1", "Item_2", "Item_3"]. It has a field - ammenities.

I would like to display the json data to my blade view?

The model:

class Property extends Model
{
   protected $casts = [
      'ammenities' => 'array',
   ];
 public function setAmmenityAttribute($value)

 {

    $this->attributes['ammenities'] = json_encode($value);

 }


  public function getAmmenityAttribute($value)

 {

    return $this->attributes['ammenities'] = json_decode($value);

 }
 }

View blade:

 <p> </p>

I get this error:

htmlspecialchars() expects parameter 1 to be string, array given


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3sGyXg8
via IFTTT

Aucun commentaire:

Enregistrer un commentaire