Exemple #1
0
 public function get($limit = 30)
 {
     $query = MavenUniqueKey::with('faqs.tags')->orderBy('sort', 'asc');
     if (!$this->_draft_flag) {
         $query->where('draft_flag', false);
     }
     if (count($this->_tags) > 0) {
         $tag_query = MavenTag::join('maven_faqs', 'maven_tags.faq_id', '=', 'maven_faqs.id');
         foreach ($this->_tags as $locale => $tags) {
             foreach ($tags as $tag) {
                 $tag_query->orWhere(function ($query) use($locale, $tag) {
                     $query->where('maven_faqs.locale', $locale)->where('maven_tags.tag', $tag);
                 });
             }
         }
         $unique_key_ids = $tag_query->lists('maven_tags.unique_key_id');
         $query->whereIn('id', $unique_key_ids);
     }
     if (count($this->_unique_keys) > 0) {
         $query->where(function ($query) {
             foreach ($this->_unique_keys as $unique_key) {
                 $query->orWhere('unique_key', $unique_key);
             }
         });
     }
     return $query->paginate($limit);
 }
Exemple #2
0
 public function destroy($id)
 {
     $maven_item = MavenUniqueKey::find($id);
     $maven_item->delete();
     $maven_items = MavenUniqueKey::orderBy('sort')->get();
     \Cahen::align($maven_items, 'sort');
     return back()->with('success', trans('maven.complete'));
 }
Exemple #3
0
 public static function selectOptions()
 {
     $options = ['' => trans('maven.choose_one')];
     $unique_keys = MavenUniqueKey::where('draft_flag', 0)->get();
     foreach ($unique_keys as $index => $unique_key) {
         $key = $index + 1;
         $options[$key] = $key;
     }
     $options_count = count($options);
     $options[$options_count] = $options_count;
     return $options;
 }