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


PHP models\Post类代码示例

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


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

示例1: Search

 public function Search($word)
 {
     $post_obj = new Post();
     $word = urldecode($word);
     $post = $post_obj->GetListPost($word);
     return view('mei.search')->with('posts', $post);
 }
开发者ID:kubill,项目名称:lumen,代码行数:7,代码来源:MainController.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Post $postModel, Request $request)
 {
     //dd($request->all());
     //$request=$request->except('_token');
     $postModel->create($request->all());
     return redirect()->route('posts');
 }
开发者ID:densem-2013,项目名称:Laravel_local,代码行数:12,代码来源:PostController.php

示例3: getOneBy

 /**
  * Fetches one post based on column value condition and status
  * @param string $column
  * @param $value
  * @param int $status
  * @return Post
  */
 public function getOneBy($column, $value, $status = Post::POST_PUBLISHED)
 {
     if ($status === null) {
         $status = Post::POST_PUBLISHED;
     }
     return $this->postModel->ofStatus($status)->where($column, $value)->take(1);
 }
开发者ID:jeremymichel,项目名称:EnsembleCMS,代码行数:14,代码来源:EloquentPostRepository.php

示例4: postNew

 /**
  * new-Action (Formularauswertung)
  */
 public function postNew()
 {
     //$validator = Validator::make(Request::all(), Post::$rules);
     //if (/*$validator->passes()*/)
     //{
     // validation has passed, save user in DB
     $post = new Post();
     $post->title = " ";
     $post->content = Request::input('content');
     $user = Auth::user();
     $post->link = '';
     $post->user_id = $user->id;
     $post->event_id = Request::input('event_id');
     $post->save();
     $response = new \stdClass();
     $response->success = true;
     $response->total = 1;
     $response->data = $post;
     return response()->json($response);
     //}
     /*else
     		{
     			// validation has failed, display error messages
     			$response = new \stdClass;
     			$response->success = false;
     			$response->total = 1;
     			return  response()->json($response);
     		}*/
 }
开发者ID:HenOltma,项目名称:EventMap,代码行数:32,代码来源:PostController.php

示例5: addReview

 public function addReview(Request $request, Post $post)
 {
     $review = new Review();
     $review->post_id = $post->id;
     $review->body = $request->post_body;
     $post->reviews()->save($review);
     return back();
 }
开发者ID:vtlkzmn,项目名称:VeebirakendusteLoomine,代码行数:8,代码来源:PostsController.php

示例6: GetAllPost

 /**
  * 返回所有文章
  */
 function GetAllPost(Request $request)
 {
     DB::connection()->enableQueryLog();
     $postSrv = new Post();
     $res = $postSrv->GetAllPost($request->all());
     $res['success'] = $res['data'] ? true : false;
     $res['sql'] = DB::getQueryLog();
     return json_encode($res, JSON_UNESCAPED_UNICODE);
 }
开发者ID:kubill,项目名称:lumen,代码行数:12,代码来源:AdminController.php

示例7: getNew

 public function getNew()
 {
     $post = new Post();
     $post->user_id = 1;
     $post->title = md5(time() * rand());
     $post->content = md5(time() * rand());
     $post->link = '';
     $post->save();
 }
开发者ID:nirebeko,项目名称:EventMap,代码行数:9,代码来源:PostController.php

示例8: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $post = new \App\Models\Post();
     $json = json_decode(\Request::input('json'));
     $receiver = \Request::input('receiver');
     $post->text = \Request::input('text');
     $post->sender_id = Auth::user()->id;
     $post->receiver_id = User::where('name', '=', $receiver)->first()->id;
     $post->save();
     return \Redirect::to('/post/');
 }
开发者ID:nvchernov,项目名称:tsargrad,代码行数:17,代码来源:PostController.php

示例9: createMessage

 /**
  * Create a new post with a text message
  *
  * @param  \App\Models\Provider  $provider
  * @param  string  $message
  * @return \App\Models\Post
  */
 public function createMessage($provider, $message)
 {
     $post = new Post();
     $post->service = $provider->service;
     $post->message = $message;
     $post->user_id = $provider->user_id;
     $post->provider_id = $provider->id;
     $post->scheduled_at = time();
     $post->save();
     return $post;
 }
开发者ID:remusb,项目名称:gemini-web,代码行数:18,代码来源:PostRepository.php

示例10: run

 /**
  * Seeds the table.
  *
  * @return void
  */
 public function run()
 {
     $post = new Post();
     $post->title = 'JSON API paints my bikeshed!';
     $post->body = 'If you\'ve ever argued with your team about the way your JSON responses should be ' . 'formatted, JSON API is your anti-bikeshedding weapon.';
     /** @var Site $site */
     $site = Site::firstOrFail();
     /** @var Author $author */
     $author = Author::firstOrFail();
     $post->site_id = $site->id;
     $post->author_id = $author->id;
     $post->save();
 }
开发者ID:greyexpert,项目名称:limoncello-shot,代码行数:18,代码来源:PostsTableSeeder.php

示例11: actionCreate

 public function actionCreate()
 {
     $data = $_POST['data'];
     $time = time();
     $data['create_at'] = $time;
     $data['user_id'] = User::getCurrentId();
     $comment = new Comment();
     $comment->attributes = $data;
     $post = new Post();
     $post->updateAll(['reply_at' => $time, 'last_reply_id' => $data['user_id']], 'id=:id', [':id' => $data['post_id']]);
     $comment->save();
     $this->redirect(array('/post/view', 'id' => $data['post_id']));
 }
开发者ID:nantmpeter,项目名称:lbsbbs,代码行数:13,代码来源:CommentController.php

示例12: savePost

 /**
  * Create or update a post.
  *
  * @param  App\Models\Post $post
  * @param  array  $inputs
  * @param  bool   $user_id
  * @return App\Models\Post
  */
 private function savePost($post, $inputs, $user_id = null)
 {
     $post->title = $inputs['title'];
     $post->summary = $inputs['summary'];
     $post->content = $inputs['content'];
     $post->slug = $inputs['slug'];
     $post->active = isset($inputs['active']);
     if ($user_id) {
         $post->user_id = $user_id;
     }
     $post->save();
     return $post;
 }
开发者ID:lvip,项目名称:Petfood,代码行数:21,代码来源:BlogRepository.php

示例13: store

 public function store(Request $request)
 {
     $input = $request->all();
     $validator = Validator::make($input, Post::getCreateRules());
     if ($validator->passes()) {
         $post = new Post();
         $post->user_id = $request->user_id;
         $post->text = $request->text;
         $post->save();
         return $this->response->array($post);
     } else {
         throw new \Dingo\Api\Exception\StoreResourceFailedException('Could not create new user.', $validator->errors());
     }
 }
开发者ID:alaevka,项目名称:angler,代码行数:14,代码来源:PostController.php

示例14: getRelationships

 /**
  * @inheritdoc
  */
 public function getRelationships($comment, array $includeRelationships = [])
 {
     /** @var Comment $comment */
     // that's an example how $includeRelationships could be used for reducing requests to database
     if (isset($includeRelationships['post']) === true) {
         // as post will be included as full resource we have to give full resource
         $post = $comment->post;
     } else {
         // as post will be included as just id and type so it's not necessary to load it from database
         $post = new Post();
         $post->setAttribute($post->getKeyName(), $comment->post_id);
     }
     return ['post' => [self::DATA => $post]];
 }
开发者ID:greyexpert,项目名称:limoncello-shot,代码行数:17,代码来源:CommentSchema.php

示例15: love

 function love(array $params)
 {
     $response = new ResponseEntity();
     DB::transaction(function () use(&$response, $params) {
         if ($params['postId']) {
             $ep = Post::find($params['postId']);
             if (!$ep) {
                 $response->setMessages(['Post is not available']);
             } else {
                 $p = new PostLove();
                 $p->post_id = $params['postId'];
                 $p->user_id = Auth::user()->id;
                 $ok = $p->save();
                 if ($ok) {
                     $response->setSuccess(true);
                 } else {
                     $response->setMessages(['Something went wrong!']);
                 }
             }
         } else {
             $response->setMessages(['Post is not available']);
         }
     });
     return $response;
 }
开发者ID:arjayads,项目名称:green-tracker,代码行数:25,代码来源:PostService.php


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