Exemplo n.º 1
0
 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]);
 }
Exemplo n.º 2
0
 public static function customCount($request, $parameters)
 {
     return Category::where('lang_id_352', $parameters['lang'])->getQuery();
 }