本文整理汇总了PHP中app\models\Post类的典型用法代码示例。如果您正苦于以下问题:PHP Post类的具体用法?PHP Post怎么用?PHP Post使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Post类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: edit
/**
* @param $id
* @param $id_acc
* @param $title
* @param $post
* @param int $category
*/
public static function edit($id, $id_acc, $title, $post, $category = 2)
{
$cleanPost = \Post::sensor($post, false);
$sql = sprintf("UPDATE `iniforum`.`posts`\n SET `post` = :post, `title` = :title, `id_category` = :category, `modified_at`=now()\n WHERE `posts`.`id` = :id AND `posts`.`id_account` = :id_acc");
$bindArray = [':id' => $id, ':id_acc' => $id_acc, ':title' => $title, ':post' => $cleanPost, ':category' => $category];
self::query($sql, $bindArray);
}
开发者ID:OckiFals,项目名称:iniforum,代码行数:14,代码来源:Comments.php
示例17: store
/**
* Store a newly created post in storage.
*
* @param CreatepostRequest $request
*
* @return Response
*/
public function store(CreatePostRequest $request)
{
$input = Request::all();
if (!empty($input['imagen'])) {
$this->carpeta = 'posts/' . $input['id_usuario'] . '/';
if (!File::exists($this->carpeta)) {
//Crear carpeta de archivos adjuntos
File::makeDirectory($this->carpeta);
}
$filename = 'posts/' . $input['id_usuario'] . '/' . $input['titulo'] . date("GisdY") . '.jpg';
$input['imagen'] = $filename;
Image::make(Input::file('imagen'))->resize(480, 360)->save($filename);
}
if (!empty($input['archivo'])) {
$this->carpeta = 'posts/' . $input['id_usuario'] . '/';
if (!File::exists($this->carpeta)) {
//Crear carpeta de archivos adjuntos
File::makeDirectory($this->carpeta);
}
$destinationPath = 'posts/' . $input['id_usuario'] . '/';
// upload path
$nombre = Input::file('archivo')->getClientOriginalName();
// getting image extension
Input::file('archivo')->move($destinationPath, $nombre);
$input['archivo'] = $destinationPath . $nombre;
}
$post = Post::create($input);
return redirect('home');
}
开发者ID:ProyectoSanClemente,项目名称:proyectoapi5.1,代码行数:36,代码来源:PostController.php
示例18: clean
/**
* TODO: In future models will have more relations which might not delete automatically. It should be tested properly
* TODO: Files should be deleted too
* Deletes all boards, threads and posts with 'is_deleted = 1', handles relation between them.
* @return array with deleted rows
*/
public static function clean()
{
$itemsToDelete = ['boardsIds' => [], 'threadsIds' => [], 'postsIds' => [], 'postDataIds' => [], 'postMessageIds' => []];
Post::getDeletedRows($itemsToDelete);
Thread::getDeletedRows($itemsToDelete);
Board::getDeletedRows($itemsToDelete);
self::getPostDataIds($itemsToDelete);
self::getPostMessageIds($itemsToDelete);
/**
* Deletes post_message's related to threads and posts
*/
$deleted['post_messages'] = PostMessage::deleteAll(['in', 'id', array_unique($itemsToDelete['postMessageIds'])]);
/**
* Deletes threads and posts because of FK
*/
$deleted['threads'] = Thread::deleteAll(['in', 'id', array_unique($itemsToDelete['threadsIds'])]);
/**
* Deleted posts and threads related to post_data
*/
$deleted['post_data'] = PostData::deleteAll(['in', 'id', array_unique($itemsToDelete['postDataIds'])]);
/**
* Deleted boards
*/
$deleted['boards'] = Board::deleteAll(['in', 'id', array_unique($itemsToDelete['boardsIds'])]);
$deleted['posts'] = $deleted['post_data'] - $deleted['threads'];
$deleted['total'] = $deleted['boards'] + $deleted['threads'] + $deleted['posts'] + $deleted['post_data'] + $deleted['post_messages'];
return $deleted;
}
开发者ID:JiltImageBoard,项目名称:jilt-backend,代码行数:34,代码来源:Cleanup.php
示例19: run
public function run()
{
DB::table('Posts')->delete();
Post::create(['title' => 'First Post', 'author' => 'Евгений', 'excerpt' => 'First Post body', 'text' => 'Content First Post body', 'published_at' => DB::raw('CURRENT_TIMESTAMP')]);
Post::create(['title' => 'Second Post', 'author' => 'Евгений', 'excerpt' => 'Second Post body', 'text' => 'Content Second Post body', 'published_at' => DB::raw('CURRENT_TIMESTAMP')]);
Post::create(['title' => 'Third Post', 'author' => 'Евгений', 'excerpt' => 'Third Post body', 'text' => 'Content Third Post body', 'published_at' => DB::raw('CURRENT_TIMESTAMP')]);
}
开发者ID:evnazarchuk,项目名称:laravel5-test,代码行数:7,代码来源:DatabaseSeeder.php
示例20: __init
public static function __init(array $options = array())
{
parent::__init($options);
$self = static::_instance();
$self->_finders['count'] = function ($self, $params, $chain) use(&$query, &$classes) {
$db = Connections::get($self::meta('connection'));
$records = $db->read('SELECT count(*) as count FROM posts', array('return' => 'array'));
return $records[0]['count'];
};
Post::applyFilter('save', function ($self, $params, $chain) {
$post = $params['record'];
if (!$post->id) {
$post->created = date('Y-m-d H:i:s');
} else {
$post->modified = date('Y-m-d H:i:s');
}
$params['record'] = $post;
return $chain->next($self, $params, $chain);
});
Validator::add('isUniqueTitle', function ($value, $format, $options) {
$conditions = array('title' => $value);
// If editing the post, skip the current psot
if (isset($options['values']['id'])) {
$conditions[] = 'id != ' . $options['values']['id'];
}
// Lookup for posts with same title
return !Post::find('first', array('conditions' => $conditions));
});
}
开发者ID:adityamooley,项目名称:Lithium-Blog-Tutorial,代码行数:29,代码来源:Post.php
注:本文中的app\models\Post类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论