示例#1
0
 public function postCheckArticle()
 {
     $checked = Input::get('checked');
     $draftArticle = DraftArticle::where('id', '=', Input::get('id'))->first();
     if ($checked == "true") {
         $draftArticle->status = '003';
         $article = Article::firstOrNew(array('draft_article_id' => $draftArticle->id));
         $article->title = $draftArticle->title;
         $article->content = $draftArticle->content;
         $article->cover = $draftArticle->cover;
         $article->digest = $draftArticle->digest;
         $article->user_id = $draftArticle->user_id;
         $article->content_format = $draftArticle->content_format;
         $article->save();
         $article->pictures()->delete();
         foreach ($draftArticle->pictures as $picture) {
             $articlePicture = App::make("ArticlePicture");
             $articlePicture->article_id = $article->id;
             $articlePicture->path = $picture->path;
             $articlePicture->thumbnail = $picture->thumbnail;
             $articlePicture->desc = $picture->desc;
             $article->pictures()->save($articlePicture);
         }
     } else {
         $draftArticle->status = '004';
     }
     $draftArticle->memo = Input::get('memo');
     if ($draftArticle->save()) {
         $response['success'] = true;
     } else {
         $response['success'] = false;
         $response['message'] = '保存失败。';
     }
     return Response::json($response);
 }
示例#2
0
 public function deleteDraftCreate($article_id)
 {
     $model = DraftArticle::where('id', '=', $article_id)->first();
     if ($model->delete()) {
         $response['success'] = true;
     } else {
         $response['success'] = false;
         $response['message'] = '保存失败。';
     }
     return Response::json($response);
 }
示例#3
0
 public function getUCenterArticle()
 {
     $articles = DraftArticle::where('user_id', '=', Auth::id())->where('status', '!=', '001')->orderBy('created_at', 'desc')->get();
     return View::make('ucenter.article')->with(compact('articles'));
 }