当前位置: 首页>>代码示例>>PHP>>正文


PHP Article::save方法代码示例

本文整理汇总了PHP中app\Article::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::save方法的具体用法?PHP Article::save怎么用?PHP Article::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Article的用法示例。


在下文中一共展示了Article::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postCreate

 /**
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postCreate(Request $request)
 {
     $data = $request->all();
     $this->article->fill($data);
     $this->article->save();
     return redirect()->to('articles/index');
 }
开发者ID:tadashi0713,项目名称:laravelsample,代码行数:11,代码来源:ArticlesController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['title' => 'required|unique:articles|max:255', 'content' => 'required', 'date_published' => 'required']);
     if ($validator->fails()) {
         return redirect('articles/create')->withErrors($validator)->withInput();
     }
     $article = new Article(array('title' => $request->get('title'), 'content' => $request->get('content'), 'date_published' => $request->get('date_published'), 'active' => $request->get('active', 0)));
     $article->save();
     if ($request->file('image')) {
         $article->image = downloadImage($request, $article->id, $request->file('image')->getClientOriginalExtension());
         $article->save();
     }
     return redirect()->route('articleEdit', array($article->id))->with('message', 'Article has been added successful!');
 }
开发者ID:evgenlytkin,项目名称:laravel,代码行数:20,代码来源:ArticleController.php

示例3: store

 public function store(Request $request)
 {
     $article = new Article();
     $article->title = $request->input('title');
     $article->save();
     return redirect('admin/article');
 }
开发者ID:yidashi,项目名称:laravel-blog,代码行数:7,代码来源:ArticleController.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $article = new Article();
     $image = Input::file('image');
     if (!empty($image)) {
         if (!$image->isValid()) {
             return Redirect::back()->withErrors(array('上传文件失败,请重新发表!'));
         }
         $clientName = $image->getClientOriginalName();
         $tmpName = $image->getFileName();
         $realPath = $image->getRealPath();
         $extension = $image->getClientOriginalExtension();
         $newName = md5(date('ymdhis') . $clientName) . '.' . $extension;
         $image->move(Utils::getUploadPath(), $newName);
         $article->image = $newName;
     }
     $article->user_id = $request->input('user_id');
     $article->title = $request->input('title');
     $article->slug = $request->input('slug');
     $article->body = $request->input('body');
     if (!$article->save()) {
         return Redirect::back()->withErrors(array('文章发表失败,请重新发表!'));
     }
     return Redirect::to('/articles');
 }
开发者ID:swordyt,项目名称:sword,代码行数:31,代码来源:ArticlesController.php

示例5: store

 public function store(Request $request, Article $article)
 {
     $article->title = $request->input('title');
     $article->body = $request->input('body');
     $article->save();
     return "Done";
 }
开发者ID:tfinnamore,项目名称:lbb,代码行数:7,代码来源:ArticleController.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     //
     $article = new Article();
     $splitter = new ImageSplitter($request->request->get('article_content'));
     if ($splitter->is_matched) {
         for ($i = 0; $i < $splitter->is_matched; $i++) {
             $res = new UploadedRes();
             $img = $splitter->getImageContent()[$i];
             $res->filename = MyUtil::save_file($img);
             $res->mime = $splitter->getMime()[$i];
             $res->save();
             $arr_id[] = $res->id;
         }
         $article->content = $splitter->getPlainContent($arr_id);
     } else {
         $article->content = $request->request->get('article_content');
     }
     $article->title = $request->request->get('article_title');
     $article->category = $request->request->get('article_category');
     $article->save();
     //        return response()->json(array("success" => "1", "new_id" => 1), 200,
     //            array('Content-Type:text/json;charset=UTF-8'));
     return response()->json(array("success" => "1", "new_id" => $article->id), 200, array('Content-Type:text/json;charset=UTF-8'));
 }
开发者ID:ryandong82,项目名称:zhsite,代码行数:30,代码来源:ArticleController.php

示例7: update

 public function update($id)
 {
     //set previous week
     $previousweek = date('Y-m-j H:i:s', strtotime('-7 days'));
     $Feed = Feed::find($id);
     echo $Feed->url . '<br>';
     $feedFactory = new FeedFactory(['cache.enabled' => false]);
     $feeder = $feedFactory->make($Feed->url);
     $simplePieInstance = $feeder->getRawFeederObject();
     //only add articles and update feed when results are found
     if (!empty($simplePieInstance)) {
         foreach ($simplePieInstance->get_items() as $item) {
             $matchThese = ['feed_id' => $Feed->id, 'url' => $item->get_permalink()];
             $results = Article::where($matchThese)->count();
             $date = $item->get_date('Y-m-j H:i:s');
             if ($results == 0 && !(strtotime($date) < strtotime($previousweek))) {
                 $article = new Article();
                 $article->feed_id = $Feed->id;
                 $article->status = 'unread';
                 $article->url = $item->get_permalink();
                 $article->subject = $item->get_title();
                 $article->content = $item->get_description();
                 $article->published = $item->get_date('Y-m-j H:i:s');
                 $article->save();
                 echo '- ' . $item->get_title() . '<br>';
             }
         }
         //update feed updated_at record
         Feed::where('id', $Feed->id)->update(['updated_at' => date('Y-m-j H:i:s')]);
         Feed::where('id', $Feed->id)->update(['feed_desc' => $simplePieInstance->get_description()]);
         Feed::where('id', $Feed->id)->update(['favicon' => $simplePieInstance->get_image_url()]);
     }
 }
开发者ID:rafix82,项目名称:rssmonster,代码行数:33,代码来源:FeedController.php

示例8: store

 public function store()
 {
     $article = new Article();
     $article->fill(\Input::only(['title', 'content']));
     $article->save();
     return redirect('/');
 }
开发者ID:nnanee,项目名称:pronoob,代码行数:7,代码来源:HomeController.php

示例9: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $article = new Article();
     $article->title = Input::get('title');
     $article->text = Input::get('text');
     $article->save();
 }
开发者ID:schen2011,项目名称:laravel,代码行数:13,代码来源:ArticlesController.php

示例10: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $rules = ['ar_title' => 'required', 'fr_title' => 'required', 'ar_contents' => 'required', 'fr_contents' => 'required', 'articlesimage' => 'required|max:10000|mimes:jpeg,png'];
     $validator = Validator::make($request->all(), $rules);
     $validator->SetAttributeNames(['ar_title' => trans('author.ar_title'), 'fr_title' => trans('author.fr_title'), 'ar_contents' => trans('author.ar_contents'), 'fr_contents' => trans('author.fr_contents'), 'articlesimage' => trans('author.articlesimage')]);
     if ($validator->fails()) {
         return redirect()->back()->withInput()->withErrors($validator);
     } else {
         if ($request->hasFile('articlesimage')) {
             $image = $request->file('articlesimage');
             if ($image->isValid()) {
                 $article = new Article();
                 $ext = $image->getClientOriginalExtension();
                 $imagename = time() . '.' . $ext;
                 $article->images = $imagename;
                 $article->ar_titles = $request->input('ar_title');
                 $article->short_ar_titles = str_limit($article->ar_titles, 15);
                 $article->fr_titles = $request->input('fr_title');
                 $article->short_fr_titles = str_limit($article->fr_titles, 15);
                 $article->ar_contents = $request->input('ar_contents');
                 $article->short_ar_contents = str_limit($article->ar_contents, 100);
                 $article->fr_contents = $request->input('fr_contents');
                 $article->short_fr_contents = str_limit($article->fr_contents, 100);
                 $article->stat = $request->input('stat');
                 $article->save();
                 session()->flash('success', trans('author.success_add'));
                 $upload = $image->move(base_path() . '/resources/views/dirassa/asset/images', $imagename);
                 return redirect()->back();
             }
         }
     }
 }
开发者ID:ewaschool,项目名称:dirassa,代码行数:38,代码来源:Articles.php

示例11: save

 private function save(Article $article, array $inputs)
 {
     $article->title = $inputs['title'];
     $article->description = $inputs['description'];
     $article->image = $inputs['image'];
     $article->save();
 }
开发者ID:eddyrajomarison,项目名称:testPHP,代码行数:7,代码来源:ArticleRepository.php

示例12: store

 public function store(ArticleRequest $request)
 {
     // Request use
     //		$input = Request::all();
     // check data input :: use ArticleRequest class
     //		$input = $request->all();
     //		Article::create($input);
     $article = new Article($request->all());
     // add image
     if ($request->hasFile('image')) {
         $image_filename = $request->file('image')->getClientOriginalName();
         $image_name = date("Ymd-His-") . $image_filename;
         $public_path = 'images/articles/';
         $destination = base_path() . $public_path;
         $request->file('image')->move($destination, $image_name);
         $article->image = $public_path . $image_name;
     }
     // add migration user_id
     /* form 1 */
     $article->user_id = Auth::user()->id;
     $article->save();
     /* form 2 */
     //		Auth::user()->articles()->save($article);
     // add many to many
     $tagsId = $request->input('tag_list');
     if (!empty($tagsId)) {
         $article->tags()->sync($tagsId);
     }
     return redirect('articles');
 }
开发者ID:tiscomsci29,项目名称:Laravel_2,代码行数:30,代码来源:ArticleController.php

示例13: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     // $rules = array(
     //'title' 	=> 'required|min:3|max:128',
     //'file' => 'mimes:jpg,gif,png'
     //);
     $this->validate($request, ['title' => 'required|unique:articles|max:255', 'author' => 'required', 'summary' => 'required', 'body' => 'required']);
     $article = new Article();
     //$article->picture ="";
     $article->title = Input::get('title');
     $article->author = Input::get('author');
     $article->summary = Input::get('summary');
     $article->body = Input::get('body');
     $article->user_id = Auth::user()->id;
     //$article->file = Input::file('file');
     // $ext = $file->guessClientExtension();
     //	$filename = $file->getClientOriginalName();
     //	$file->move(public_path().'/data', md5(date('YmdHis').$filename).'.'.$ext);
     //	$pictrue = md5(date('YmdHis').$filename).'.'.$ext;
     if ($article->save()) {
         return Redirect::to('admin');
     } else {
         return Redirect::back()->withInput()->withErrors('保存失败!');
     }
 }
开发者ID:babyanzichen,项目名称:laravel5,代码行数:30,代码来源:ArticlesController.php

示例14: index

 public function index()
 {
     $article = new Article();
     $article->title = 'feiyi';
     $article->content = '哈哈';
     $result = $article->save();
     var_dump($result);
 }
开发者ID:liuhai2013,项目名称:feiyi,代码行数:8,代码来源:UserController.php

示例15: store

 /**
  * @param ArticleRequest $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function store(ArticleRequest $request)
 {
     $article = new Article($request->all());
     $article->user_id = 1;
     $article->save();
     //        \Auth::user()->articles()->save($article);
     return redirect('articles');
 }
开发者ID:andreamswick,项目名称:tbsza_v2,代码行数:12,代码来源:ArticlesController.php


注:本文中的app\Article::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。