Esempio n. 1
0
 protected function merge(Request $request)
 {
     $tagIds = $request->input('tags');
     $firstTag = Tag::find($tagIds[0]);
     if (!$firstTag) {
         return;
     }
     foreach ($tagIds as $tagId) {
         $tag = Tag::find($tagId);
         if (!$tag) {
             continue;
         }
         $firstTag->merge($tag);
     }
 }
Esempio n. 2
0
 public function delete()
 {
     $id = Input::get('id');
     $validator = Validator::make(array('id' => $id), array('id' => 'required|integer'));
     if ($validator->fails()) {
         return $this->responseJson(false, $validator->messages(), 101);
     }
     $tag = Tag::find($id);
     if (!$tag) {
         return $this->responseJson(false, "不存在该标签!", 102);
     }
     $tag->delete();
     ArticleAttribute::where('attribute_key', 'tag_id')->where('attribute_value', $id)->delete();
     return $this->responseJson(true, "成功删除标签!", 200);
 }
Esempio n. 3
0
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', 'IndexController@index');
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
Route::get('/test', function () {
    DB::listen(function ($sql, $bindings, $time) {
        dump($sql);
    });
    $data = \App\Model\Tag::find(68262);
    dump($data);
    //return $data;
});
Route::get('post/search', 'PostController@search');
Route::get('post/random', 'PostController@random');
Route::get('post/tag/{id}', 'PostController@tag');
Route::get('post/category/{id}', ['as' => 'post.category', 'uses' => 'PostController@category']);
Route::get('post/add-tag/{post_id}/{tag_id}', ['as' => 'post.tag.add', 'uses' => 'TagController@addToPost']);
Route::get('post/del-tag/{post_id}/{tag_id}', ['as' => 'post.tag.del', 'uses' => 'TagController@delTagByPost']);
Route::get('post/user/{id}', 'PostController@user');
Route::resource('user', 'UserController');
Route::resource('post', 'PostController');
Route::resource('category', 'CategoryController');
Route::resource('tag', 'TagController');
Route::resource('file', 'FileController');
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  * @return Response
  */
 public function edit($id)
 {
     //
     return backendView('edit', ['tag' => Tag::find($id)]);
 }