Jacob
Jacob

Reputation: 137

Is there any way we can check if relation value exists then return array else return blank array

When i do dd i get

{
    "data": [
        {
            "id": 1,
            "name": "Alex",
            "active": "1",
            "address": [
                {
                    "id": 1,
                    "street_address": "C1",
                    "city": "New york",
                    "zip": "10001"
               }
            ],
            "meta_data": [],
        }
  ],
}

Since no meta_data avail it should return data to be blank how this could achieve please guide thanks.

Is there any way please suggest.

Upvotes: 0

Views: 26

Answers (1)

Jinal Somaiya
Jinal Somaiya

Reputation: 1971

try this:

Table::has('realtion_name')->get();

Upvotes: 1

Related Questions