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


PHP Post::fill方法代码示例

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


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  CreatePostRequest $request
  * @return Response
  */
 public function store(CreatePostRequest $request, $category_id)
 {
     // save post
     $post = new Post();
     $post->fill($request->all());
     $post->category_id = $category_id;
     $post->save();
     // if have attachment, create the attachment record
     if ($request->hasFile('attachment')) {
         // generate filename based on UUID
         $filename = Uuid::generate();
         $extension = $request->file('attachment')->getClientOriginalExtension();
         $fullfilename = $filename . '.' . $extension;
         // store the file
         Image::make($request->file('attachment')->getRealPath())->resize(null, 640, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         })->save(public_path() . '/attachments/' . $fullfilename);
         // attachment record
         $attachment = new Attachment();
         $attachment->post_id = $post->id;
         $attachment->original_filename = $request->file('attachment')->getClientOriginalName();
         $attachment->filename = $fullfilename;
         $attachment->mime = $request->file('attachment')->getMimeType();
         $attachment->save();
     }
     return redirect('category/' . $category_id . '/posts');
 }
开发者ID:NCKU-Official,项目名称:ncku-report-server,代码行数:34,代码来源:PostController.php

示例2: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, Post $post)
 {
     // update post
     $post->user_id = \Auth::user()->id;
     $post->slug = $request->get('title');
     $post->html = $request->get('markdown');
     $post->fill($request->all());
     $post->featured = $request->has('featured') ? 1 : 0;
     $post->save();
     return redirect()->to('admin');
 }
开发者ID:jeremytubbs-deprecated,项目名称:L51-Start-Here,代码行数:17,代码来源:PostsController.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $post = new Post();
     $input = $request->all();
     $input['post_author'] = Auth::user()->id;
     $input['post_featured_image_url'] = "http://lorempixel.com/1000/500/fashion/" . random_int(1, 10);
     $post->fill($input)->save();
     Session::flash('status', 'Your blog post has been created successfully!');
     $posts = Post::all();
     return view('posts.show', ['post' => $post]);
 }
开发者ID:kfwong,项目名称:cvwo-assignment-1,代码行数:17,代码来源:PostController.php

示例4: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $post = new Post();
     $post->fill($request->all());
     $post->user_id = Auth::user()->id;
     $post->slug = str_slug($post->title);
     $post->draft = !empty($request->draft);
     $post->save();
     $tags = explode(',', $request->tags);
     foreach ($tags as $tag) {
         $tag_ids[] = Tag::getId($tag);
     }
     $post->tags()->sync($tag_ids);
     return redirect('admin/posts');
 }
开发者ID:vladzur,项目名称:werken,代码行数:21,代码来源:PostsController.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @param CreatePostRequest $request
  * @return Response
  */
 public function store(CreatePostRequest $request)
 {
     $post = new Post();
     $post->fill($request->all());
     $post->user_id = Auth::id();
     if ($request->hasFile('image')) {
         $file = $request->file('image');
         $patch = 'images/posts/';
         $name = $post->title . '.' . $file->getClientOriginalExtension();
         $image = $patch . $name;
         Image::make($file)->fit(1140, 400)->save($image);
         $post->image = $image;
     }
     $post->save();
     $message = trans('messages.post_created_successfully');
     Flash::success($message);
     return redirect()->route('admin.posts.index');
 }
开发者ID:jrafaelca,项目名称:infrea,代码行数:24,代码来源:PostsController.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $input = $request->input('post');
     try {
         $validateData = $this->_validation->validate($input);
     } catch (ValidationException $e) {
         $errors['error'] = $e->get_errors();
         return Response::json($errors, 422);
     }
     $createPost = new Post();
     $response = ['post' => []];
     try {
         $statusCode = 200;
         $response['post'] = $createPost->fill($input);
         $createPost->save();
     } catch (\Exception $e) {
         Log::info($e);
         $statusCode = 400;
     } finally {
         return Response::json($response, $statusCode);
     }
 }
开发者ID:herman-rogers,项目名称:WestCoastSoftwareWebsite,代码行数:27,代码来源:PostController.php


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