public function getByRestaurantLocationId($id) { $vendorLocationWithAttributes = VendorLocation::with('attributesBoolean', 'attributesDate', 'attributesInteger', 'attributesFloat', 'attributesText', 'attributesVarChar', 'attributesSingleSelect', 'attributesMultiSelect', 'schedules')->findOrFail($id); /*->wherehas('vendor.vendorType',function($q) { $q->where('type','Restaurants'); })->first();*/ //dd(array_flatten($vendorLocationWithAttributes->schedules->toArray())); $this->populateVendorAttributes($vendorLocationWithAttributes->attributesBoolean); $this->populateVendorAttributes($vendorLocationWithAttributes->attributesInteger); $this->populateVendorAttributes($vendorLocationWithAttributes->attributesFloat); $this->populateVendorAttributes($vendorLocationWithAttributes->attributesDate); $this->populateVendorAttributes($vendorLocationWithAttributes->attributesText); $this->populateVendorAttributes($vendorLocationWithAttributes->attributesVarChar); $this->populateVendorAttributes($vendorLocationWithAttributes->attributesSingleSelect); $this->populateVendorMultiSelectAttributes($vendorLocationWithAttributes->attributesMultiSelect); $this->populateVendorSchedules($id); return ['RestaurantLocation' => VendorLocation::find($id), 'schedules' => $this->schedules, 'attributes' => $this->attributes]; }