示例#1
0
 public function styleAutocomplete($term)
 {
     $terms = [];
     foreach (Style::where('name', 'like', "%" . $term . "%")->get() as $style) {
         if ($style->style_id) {
             $parent = " (" . Style::find($style->style_id)->name . ")";
         } else {
             $parent = "";
         }
         $terms[] = ['name' => $style->name, 'id' => $style->id, 'pretty_name' => $style->name . $parent];
     }
     return Response::json($terms);
 }
示例#2
0
 /**
  * Submit style form
  */
 public function saveStyle()
 {
     if (Input::get('style_id') != null) {
         //edit style
         $style = Style::find(Input::get('style_id'));
     } else {
         //create style
         $style = new Style();
     }
     if (Input::get('parent_style') != null) {
         $parent_style = Style::where('name', Input::get('parent_style'))->first();
         if ($parent_style) {
             $parent_style_id = $parent_style->id;
         }
     } else {
         $parent_style_id = null;
     }
     $style->name = Input::get('name');
     $style->description = Input::get('description');
     $style->style_id = $parent_style_id;
     $style->wikipedia_url = Input::get('wikipedia');
     $style->save();
     return Redirect::back()->withMessage('Style created correctly');
 }