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


PHP app\Post类代码示例

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


在下文中一共展示了Post类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: newPost

 /**
  * Create a new post
  * @param string $body Content of post, will be run through filters
  * @param integer $threadid Thread ID
  * @param integer| $posterid Poster's ID. Defaults to currently authenticated user
  * @param bool|false $hidden Is the post hidden from normal view?
  * @param bool|true $save Should the post be automatically saved into the database?
  * @return Post The resulting post object
  */
 public static function newPost($body, $threadid, $posterid = null, $hidden = false, $save = true)
 {
     // Check users rights
     if (!Auth::check() && $posterid === null) {
         abort(403);
         // 403 Forbidden
     }
     // Check thread
     $thread = Thread::findOrFail($threadid);
     if ($thread->locked) {
         abort(403);
         // 403 Forbidden
     }
     // Run post through filters
     $body = PostProcessor::preProcess($body);
     // Create new post
     $post = new Post();
     $post->thread_id = $threadid;
     $post->poster_id = Auth::user()->id;
     $post->body = $body;
     $post->hidden = $hidden;
     // defaults to false
     // Put post into database
     if ($save) {
         $post->save();
     }
     return $post;
 }
开发者ID:harmjanhaisma,项目名称:clearboard,代码行数:37,代码来源:Post.php

示例3: store

 public function store(PostsRequest $request)
 {
     $post = new Post();
     $post->title = $request->input('title');
     $post->content = $request->input('content');
     $post->save();
 }
开发者ID:Kristian95,项目名称:LaravelApp,代码行数:7,代码来源:PostsController.php

示例4: removeCategory

 /**
  * Remove given category from given post.
  *
  * @param Post $post
  * @param Category $category
  * @return void
  * @throws NotFoundHttpException
  */
 public function removeCategory(Post $post, Category $category)
 {
     if (!$post->categories->contains($category->id)) {
         throw new NotFoundHttpException("Category doesn't exist on Post #" . $post->id);
     }
     $post->categories()->detach($category->id);
 }
开发者ID:lolzballs,项目名称:website,代码行数:15,代码来源:PostRepository.php

示例5: apiStoreReply

 /**
  * API to store a new reply
  */
 public function apiStoreReply(ReplyRequest $request, Post $post)
 {
     logThis(auth()->user()->name . ' replied to ' . $post->title);
     $request->merge(['user_id' => auth()->user()->id]);
     $reply = $post->replies()->create($request->all());
     return $reply;
 }
开发者ID:goatatwork,项目名称:goldaccess-support,代码行数:10,代码来源:RepliesController.php

示例6: store

 public function store(Request $request)
 {
     $post = new Post();
     $post->title = $request->title;
     $post->body = $request->body;
     $post->save();
 }
开发者ID:samyerkes,项目名称:blog.samyerkes.com,代码行数:7,代码来源:PostController.php

示例7: postAddContent

 public function postAddContent()
 {
     $url = Input::get('url');
     if (strpos($url, 'youtube.com/watch?v=') !== FALSE) {
         $type = 'youtube';
         $pieces = explode("v=", $url);
         $mediaId = $pieces[1];
     } else {
         if (strpos($url, 'vimeo.com/channels/') !== FALSE) {
             $type = 'vimeo';
             $pieces = explode("/", $url);
             $mediaId = $pieces[5];
         } else {
             if (strpos($url, 'soundcloud.com/') !== FALSE) {
                 $type = 'soundcloud';
                 $mediaId = 'null';
             } else {
                 $type = 'other';
                 $mediaId = 'null';
             }
         }
     }
     $userId = Auth::id();
     $post = new Post();
     $post->url = $url;
     $post->type = $type;
     $post->userId = $userId;
     $post->mediaId = $mediaId;
     $post->save();
     return redirect('/content')->with('success', 'Post successfully created!');
 }
开发者ID:ChristofVanoppen,项目名称:PHP2-MiniCMS,代码行数:31,代码来源:PostController.php

示例8: destroy

 public function destroy(Post $post)
 {
     $vote = Vote::where(['post_id' => $post->id, 'user_id' => Auth::user()->id])->first();
     $vote->delete();
     $post->decrement('vote_count');
     return response([]);
 }
开发者ID:enhive,项目名称:vev,代码行数:7,代码来源:VoteController.php

示例9: create

 public function create($name, $title)
 {
     $post = new Post();
     $post->name = $name;
     $post->title = $title;
     $post->save();
     return $post;
 }
开发者ID:edisonthk,项目名称:laravel5_reactjs,代码行数:8,代码来源:PostService.php

示例10: store

 public function store(Request $request, Post $post)
 {
     $comment = Comment::create($request->all());
     $post->comments()->save($comment);
     Score::create(['user_id' => Auth::user()->id, 'reference' => 'comment', 'score' => 2]);
     Auth::user()->increment('scores', 2);
     return redirect()->to('posts/' . $post->slug);
 }
开发者ID:enhive,项目名称:vev,代码行数:8,代码来源:CommentController.php

示例11: handle

 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $post = new Post();
     $post->user_id = $this->user_id;
     $post->title = $this->title;
     $post->message = $this->message;
     $post->save();
 }
开发者ID:pastoralbanojr,项目名称:BlogNow,代码行数:13,代码来源:StorePost.php

示例12: destroy

 public function destroy(Post $post)
 {
     if ($post->image && \File::exists(public_path() . "/" . $post->image)) {
         \File::delete(public_path() . "/" . $post->image);
     }
     $post->delete();
     return redirect()->route("backend.post.index");
 }
开发者ID:erayaydin,项目名称:erayaydin,代码行数:8,代码来源:PostController.php

示例13: create

 public function create(Request $request)
 {
     $this->validate($request, ['name' => 'required', 'topic' => 'required']);
     $post = new Post();
     $post->name = $request->input('name');
     $post->topic = $request->input('topic');
     $post->save();
     return response()->success(compact('post'));
 }
开发者ID:qjacquet,项目名称:laravel-angular,代码行数:9,代码来源:PostsController.php

示例14: addNewPost

 public function addNewPost()
 {
     $title = Input::get("title");
     $body = Input::get("body");
     $importer_id = Auth::user()['attributes']['id'];
     $v = new Post();
     $v->title = $title;
     $v->body = $body;
     $v->importer_id = $importer_id;
     $v->save();
 }
开发者ID:navid1391,项目名称:q._w-1947__bvcxryu--.-.-WWWQ___X_x_O_o,代码行数:11,代码来源:postController.php

示例15: changeStatus

 public function changeStatus(Post $post)
 {
     if ($post->status == 1) {
         $post->update(['status' => 0]);
         Flash::success(trans('admin/messages.postBan'));
     } elseif ($post->status == 0) {
         $post->update(['status' => 1]);
         Flash::success(trans('admin/messages.postActivate'));
     }
     return redirect()->back();
 }
开发者ID:emadmrz,项目名称:Hawk,代码行数:11,代码来源:PostManagementController.php


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