Esempio n. 1
0
 public function json(Request $request)
 {
     $tags = Tag::where('name', 'LIKE', '%' . $request->input('term') . '%')->get();
     $out = array();
     foreach ($tags as $tag) {
         $out[] = array('label' => $tag->name);
     }
     return Response::json($out);
 }
 public function storeTags($blog, $tags)
 {
     $tag_array = explode(',', $tags);
     foreach ($tag_array as $tag) {
         $t = Tag::where('tag', $tag)->first();
         if (is_null($t)) {
             $blog->tags()->save(new Tag(['tag' => $tag]));
         } else {
             $blog->tags()->save($t);
         }
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function update(TagsForm $result, $id)
 {
     //
     try {
         if (Tag::where('id', $id)->update(['name' => $result->input('name')])) {
             Notification::success('更新成功');
             return redirect()->route('backend.tags.index');
         }
     } catch (\Exception $e) {
         return redirect()->back()->withErrors(array('error' => $e->getMessage()))->withInput();
     }
 }