當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。