Пример #1
0
 public function update($id, CreateArticleRequest $request)
 {
     //dd($request->input('tag_list'));
     $article = Article::find($id);
     $article->update($request->all());
     $article->tag()->sync($request->input('tag_list'));
     //return redirect('articles');
 }
 public function store(CreateArticleRequest $request)
 {
     $input = $request->all();
     $input['published_at'] = Carbon::now();
     $article = new Article($input);
     Auth::user()->articles()->save($article);
     //Article::create($input);
     return redirect('articles');
 }
 /**
  * Stores an article in the database
  * @param  CreateArticleRequest $request
  * @return view
  */
 public function store(CreateArticleRequest $request)
 {
     //Extract to function
     $tags = $request->input('tagList');
     foreach ($tags as $key => $value) {
         if (!is_numeric($value)) {
             $newTag = Tag::create(['name' => $value]);
             $tags[$key] = (string) $newTag->id;
         }
     }
     $article = \Auth::user()->articles()->create($request->all());
     $article->tags()->attach($tags);
     \Session::flash('flash_message', 'Your article has been created!');
     return redirect('articles');
 }
 function store(CreateArticleRequest $request)
 {
     //$input = Request::get('title');
     //$input = Request::all();
     /*$article  = new Article;
     
         	$article->title = $input['title'];
         	$article->body 	= $input['body'];*/
     //$article = new Article(['title'=>'This is new one from file','body'=>'New Body From file']);
     //$input['published_at'] = Carbon::now();
     //Article::create($input);
     //Article::create(Request::all());
     Article::create($request->all());
     //return $input;
     return redirect('articles');
 }
 /**
  * @param CreateArticleRequest $request
  * @return mixed
  */
 public function store(CreateArticleRequest $request)
 {
     //        $pubat = Request::input('published_at');
     //        dd($pubat);
     //        $input = Request::all(); //fetch HTTP input data as an array
     //        dd($input);
     //        Instead of using static call Carbon::now()
     //        $obj = new Carbon();
     //        $input['published_at'] = $obj->now();
     //        The same as above but using a static call
     //        $input['published_at'] = Carbon::now();
     //        Article::create($input); //call static method create to pass input data to Article Model
     //        return redirect('articles');
     Article::create($request->all());
     //        return $request->all(); //return HTTP Request parameters as JSON i.e: {"_token": "foo","title": "foo","body": "foo","published_at": "2016-01-30"}
     return redirect('articles');
 }
Пример #6
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Requests\CreateArticleRequest  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateArticleRequest $request)
 {
     $tags = $request->input('tags');
     $currentTags = array_filter($tags, 'is_numeric');
     $newTags = array_diff($tags, $currentTags);
     foreach ($newTags as $newTag) {
         if ($tag = Tag::create(['name' => $newTag])) {
             $currentTags[] = $tag->id;
         }
     }
     // $article = Auth::user()->articles()->create($request->all());
     $article = Article::create($request->all());
     $article->tags()->attach($currentTags);
     // $article->tags()->sync($currentTags);
     if ($request->hasFile('cover')) {
         $this->uploadFile($request->file('cover'));
     }
     return redirect('admin/content');
 }
Пример #7
0
 public function store(CreateArticleRequest $request)
 {
     if (Auth::guest()) {
         return view('welcome');
     } elseif (Auth::user()->level < 1) {
         return view('welcome');
     }
     $input = $request->all();
     $article = new Article();
     $article->title = $input['title'];
     $article->text = $input['body'];
     $date_to_pub = Carbon::createFromFormat('Y/m/d', $input['date_to_publish']);
     $date_to_pub->hour = 0;
     $date_to_pub->minute = 0;
     $date_to_pub->second = 0;
     $article->date_to_publish = $date_to_pub;
     $article->created_by = Auth::id();
     $article->approved = 1;
     // De momento vamos aprovar directamente os artgios, pois são escritos por experts só.
     $article->save();
     return redirect('home');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Article $article
  * @return Response
  */
 public function update(Article $article, CreateArticleRequest $request)
 {
     $article->update($request->all());
     $this->syncTags($article, $request->input('tag_list'));
     return redirect('articles');
 }
Пример #9
0
 public function store(CreateArticleRequest $request)
 {
     Article::create($request->all());
     return redirect('articles');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function update($id, CreateArticleRequest $request, Article $article)
 {
     $article_to_update = $article->find($id);
     $uploaded_image = $request->file('image_file');
     $parameter = $request->all();
     if (isset($uploaded_image)) {
         $ext = $uploaded_image->getClientOriginalExtension();
         $newImageName = $article_to_update->id . "." . $ext;
         $uploaded_image->move(base_path() . '/public/img/uploads/article/', $newImageName);
         Image::make(base_path() . '/public/img/uploads/article/' . $newImageName, array('width' => 170, 'height' => 120))->save(base_path() . '/public/img/uploads/article/' . $newImageName);
         unset($parameter['image_file']);
         $parameter['image'] = $newImageName;
         $article_to_update->update($parameter);
     } else {
         $parameter['image'] = $article_to_update->image;
         $article_to_update->update($parameter);
     }
     Session::flash('message', 'The article was successfully edited!.');
     Session::flash('flash_type', 'alert-success');
     return redirect('articles');
 }
Пример #11
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function update(CreateArticleRequest $request, $id)
 {
     $article = Article::findOrFail($id);
     $article->update($request->all());
     return redirect(route('articles.show', $id));
 }
Пример #12
0
 /**
  * Save a new article.
  *
  * @param CreateArticleRequest $request
  */
 private function createArticle(CreateArticleRequest $request)
 {
     $article = Auth::user()->articles()->create($request->all());
     //$article->uploads()->sync(Upload::put($request->file('cover')));
     $tag_list = $request->input('tag_list');
     if (!empty($tag_list)) {
         $this->syncTags($article, $request->input('tag_list'));
     }
     return $article;
 }
 public function store(CreateArticleRequest $request)
 {
     $articles = new Article($request->all());
     return redirect('cerebro');
 }
Пример #14
0
 public function update(Requests\CreateArticleRequest $request, $id)
 {
     $article = Article::findOrFail($id);
     $oldCateId = $article->cate_id;
     $article->update($request->all());
     $oldTags = Tag::where(['user_id' => \Auth::user()->id, 'article_id' => $id])->delete();
     $newTags = $request->get('tags');
     if ($newTags && $newTags != "多个标签以,分隔") {
         $newTags = str_replace(',', ',', $newTags);
         //中文状态逗号,替换成英文逗号
         $newTags = trim($newTags, ',');
         $arr = explode(',', $newTags);
         //拆分标签入库
         foreach ($arr as $k => $v) {
             Tag::create(array('tag' => $v, 'user_id' => \Auth::user()->id, 'article_id' => $article->id));
         }
     }
     //更新分类数据
     if ($oldCateId != $request->get('cate_id')) {
         //有分类的文章才执行原有分类自增
         if ($article->cate_id > 0) {
             Cate::where('id', $oldCateId)->decrement('count');
             Cate::where('id', $request->get('cate_id'))->increment('count');
         } else {
             //
         }
     }
     return redirect('/articles');
 }
Пример #15
0
 public function store(Requests\CreateArticleRequest $request)
 {
     $article = new Article($request->all());
     \Auth::user()->articles()->save($article);
     return redirect('articles');
 }
 /**
  * Save a new article.
  *
  * @param ArticleRequest $request
  * @return Response
  */
 public function postSaveArticle(CreateArticleRequest $request)
 {
     auth()->user()->articles()->create($request->all());
     return redirect('blog');
 }
Пример #17
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update($id, CreateArticleRequest $request)
 {
     $article = Article::findOrFail($id);
     if ($request->user()->cannot('update-post', $article)) {
         abort(403);
     }
     $this->authraize($article);
     $article->update($request->all());
     Request::session()->flash('success', 'Uptodate successful!');
     return redirect("admin/articles/" . $id . "/edit");
 }
Пример #18
0
 /**
  * Сохранение нового acticle
  * @param  Requests\CreateArticleRequest $request [description]
  * @return [type]                                 [description]
  */
 public function createArticle(Requests\CreateArticleRequest $request)
 {
     $article = Auth::user()->articles()->create($request->all());
     $this->syncTags($article, $request->input('tags_list'));
     return $article;
 }
Пример #19
0
 public function update($id, CreateArticleRequest $request)
 {
     $article = Article::findOrFail($id);
     $article->update($request->all());
     return redirect('articles');
 }
Пример #20
0
 public function update(Article $article, CreateArticleRequest $request)
 {
     $input = $request->all();
     $article->update($input);
     $article->tag()->sync($request['tag_list']);
     return redirect('articles');
 }
Пример #21
0
 public function store(Requests\CreateArticleRequest $request)
 {
     $article = new Article($request->all());
     Sentinel::getUser()->articles()->save($article);
     return redirect('/articles');
 }