jeudi 26 mars 2020

How to loop through all assets and check for a key, if the key matches, continue and display all assets? PHP/Laravel

I have a collection of $liquidAssets and I want to loop through all of them and display only the $liquidAssets which maches the key, how could I do this? Do I need to firstly make a collection an array?

public function displayAssets()
{
    $name = 'name';
    $token = 'token';
    $themeId = '123';

    $assetAPI = new Asset($name, $token, $themeId);

    $assets = $assetAPI->all();
    $liquidAssets = collect($assets->assets)->where('content_type', 'text/x-liquid');
    $liquidAssets = $liquidAssets->all();

    foreach($liquidAssets as $asset) {
        $response = $assetAPI->get($asset->key);
        dd($response);
    }
}

The logic is this:

  • loop through all assets
  • check if in array there is a key ld+json
  • display all assets with ld+json

Now I get only the assets of a one asset



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

Aucun commentaire:

Enregistrer un commentaire