本文整理汇总了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);
}
示例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');
}
示例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);
}
示例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);
}*/
}
示例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();
}
示例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);
}
示例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();
}
示例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/');
}
示例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;
}
示例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();
}
示例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']));
}
示例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;
}
示例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());
}
}
示例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]];
}
示例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;
}