mercredi 1 avril 2020

How can I display arrays one value in Laravel/PHP?

I have created an array and I want to display the array's value opens and closes

Shop class:

public function jsonLDFields()
{
    return $this->hasOne(JsonLDFields::class);
}

JsonLDFields class:

public function shop()
{
    return $this->belongsTo('App\User');
}

A shop has jsonLDFields, jsonLDFields has a DB column value for store_opens / store_closes

store_opens[store_times][monday][opens]

"store_opens" => array:1 [▼
    "store_times" => array:7 [▼
      "Monday" => array:1 [▼
        "opens" => "09:00"
      ]
      "Tuesday" => array:1 [▼
        "opens" => "09:00"
      ]
      "Wednesday" => array:1 [▼
        "opens" => "09:00"
      ]
      "Thursday" => array:1 [▼
        "opens" => "09:00"
      ]
      "Friday" => array:1 [▼
        "opens" => "09:00"
      ]
      "Saturday" => array:1 [▼
        "closes" => "10:00"
      ]
      "Sunday" => array:1 [▼
        "opens" => "10:00"
      ]
    ]
  ]

When I try to display it like this:

$shop->jsonLDFields->store_closes.

The result is all arrays values.

When I try to display it like this:

$shop->jsonLDFields->store_closes['opens']

The result is null.

When I try to display it like this:

$shop->jsonLDFields->store_opens['store_times']['Monday']['opens']

The result is null.

How could I display the opens and closes values in the view?



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

Aucun commentaire:

Enregistrer un commentaire