Example #1
0
 public function apiCheckSlug()
 {
     $slug = $this->request->input('slug');
     $query = Service::where('lang_id_153', $this->request->input('lang'))->where('slug_153', $slug);
     if ($this->request->has('id')) {
         $query->whereNotIn('id_153', [$this->request->input('id')]);
     }
     $nObjects = $query->count();
     if ($nObjects > 0) {
         $suffix = 0;
         while ($nObjects > 0) {
             $suffix++;
             $slug = $this->request->input('slug') . '-' . $suffix;
             $nObjects = Service::where('lang_id_153', $this->request->input('lang'))->where('slug_153', $slug)->count();
         }
     }
     return response()->json(['status' => 'success', 'slug' => $slug]);
 }
Example #2
0
 public function editCustomRecord($parameters)
 {
     $parameters['services'] = Service::where('lang_id_153', $parameters['lang']->id_001)->get();
     $parameters['environments'] = Environment::where('lang_id_150', $parameters['lang']->id_001)->get();
     $parameters['decorations'] = Decoration::where('lang_id_151', $parameters['lang']->id_001)->get();
     $parameters['relationships'] = Relationship::where('lang_id_152', $parameters['lang']->id_001)->get();
     $parameters['publications'] = Publication::all();
     $parameters['restaurantTypes'] = array_map(function ($object) {
         $object->name = trans($object->name);
         return $object;
     }, config('hotels.restaurantTypes'));
     // get attachments elements
     $attachments = AttachmentLibrary::getRecords($this->package, 'hotels-hotel', $parameters['object']->id_170, $parameters['lang']->id_001);
     $parameters['products'] = Product::builder()->where('active_111', true)->where('lang_id_112', $parameters['lang']->id_001)->get();
     // get attachments products with photo list
     $parameters['attachmentsProducts'] = Attachment::builder()->where('lang_id_016', $parameters['lang']->id_001)->where('resource_id_016', 'market-product')->where('family_id_016', config('hotels.idAttachmentsFamily.productList'))->get()->keyBy('object_id_016');
     // merge parameters and attachments array
     $parameters['customFieldGroups'] = CustomFieldGroup::builder()->where('resource_id_025', 'hotels-hotel')->get();
     $parameters['attachmentFamilies'] = AttachmentFamily::getAttachmentFamilies(['resource_id_015' => 'hotels-hotel']);
     $parameters = array_merge($parameters, $attachments);
     // get hotel products
     $parameters['hotelProducts'] = $parameters['object']->getHotelProducts->keyBy('product_id_177');
     $parameters['hotelProductsIds'] = json_encode($parameters['hotelProducts']->keys()->map(function ($item, $key) {
         return strval($item);
     }));
     return $parameters;
 }
Example #3
0
 public static function customCount($request, $parameters)
 {
     return Service::where('lang_id_153', $parameters['lang'])->getQuery();
 }