public function apiCheckSlug() { $slug = $this->request->input('slug'); $query = Category::where('lang_id_352', $this->request->input('lang'))->where('slug_352', $slug); if ($this->request->input('id')) { $query->whereNotIn('id_352', [$this->request->input('id')]); } $nObjects = $query->count(); if ($nObjects > 0) { $suffix = 0; while ($nObjects > 0) { $suffix++; $slug = $this->request->input('slug') . '-' . $suffix; $nObjects = Category::where('lang_id_352', $this->request->input('lang'))->where('slug_352', $slug)->count(); } } return response()->json(['status' => 'success', 'slug' => $slug]); }
public static function customCount($request, $parameters) { return Category::where('lang_id_352', $parameters['lang'])->getQuery(); }
public function editCustomRecord($parameters) { $parameters['sections'] = Section::all(); $parameters['families'] = ArticleFamily::all(); $parameters['tags'] = []; $tags = Tag::builder()->where('lang_id_358', $parameters['object']->lang_id_355)->get(); foreach ($tags as $tag) { $parameters['tags'][] = ['value' => $tag->id_358, 'label' => $tag->name_358]; } $objectTags = $parameters['object']->getTags; $parameters['selectTags'] = []; foreach ($objectTags as $objectTag) { $parameters['selectTags'][] = ['value' => $objectTag->id_358, 'label' => $objectTag->name_358]; } $parameters['categories'] = Category::builder()->where('lang_id_352', $parameters['object']->lang_id)->get(); $parameters['statuses'] = [(object) ['id' => 0, 'name' => trans('cms::pulsar.draft')], (object) ['id' => 1, 'name' => trans('cms::pulsar.publish')]]; // get attachments elements $attachments = AttachmentLibrary::getRecords('cms', 'cms-article', $parameters['object']->id_355, $parameters['object']->lang_id); // merge parameters and attachments array $parameters['attachmentFamilies'] = AttachmentFamily::getAttachmentFamilies(['resource_id_015' => 'cms-article']); $parameters = array_merge($parameters, $attachments); return $parameters; }