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


PHP Post::find方法代码示例

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


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

示例1: index

 function index()
 {
     $params = array('fields' => array('title', 'body', 'hoge'), 'order' => array('_id' => -1), 'limit' => 35, 'page' => 1);
     $results = $this->Post->find('all', $params);
     //$result = $this->Post->find('count', $params);
     $this->set(compact('results'));
 }
开发者ID:rafaelqueiroz,项目名称:mongoDB-Datasource,代码行数:7,代码来源:posts_controller.php

示例2: getArticle

 public function getArticle($id)
 {
     $post = Post::find($id);
     $sidePosts = Post::take(3)->offset(1)->orderby('id', 'desc')->get();
     $comments = Comment::where('post_id', $id)->get();
     return View::make('pages.view')->with(compact('post', 'sidePosts', 'comments'))->with('pageTitle', $post->title);
 }
开发者ID:resethread,项目名称:elycee,代码行数:7,代码来源:BlogController.php

示例3: testCommentsReturnRelatedComments

 public function testCommentsReturnRelatedComments()
 {
     $post1 = Post::find(1);
     $post2 = Post::find(2);
     $this->assertEquals(5, $post1->comments()->count());
     $this->assertEquals(1, $post2->comments()->count());
 }
开发者ID:jackw899,项目名称:laravel-commentable,代码行数:7,代码来源:PostRelationsTest.php

示例4: edit

 public function edit($id)
 {
     $post = Post::find($id);
     $this->authorOrAdminPermissioinRequire($post->user_id);
     $category_selects = Category::lists('name', 'id');
     return View::make('posts.create_edit', compact('category_selects', 'post'));
 }
开发者ID:Kouga-Huang,项目名称:laravel-blog,代码行数:7,代码来源:PostsController.php

示例5: articleAction

 public function articleAction()
 {
     $posts = Post::find(['type = "post" AND id_web = "' . $this->auth->id_web . '" order by id desc']);
     $paginator = new PaginatorModel(array("data" => $posts, "limit" => $this->params->limit, "page" => $this->params->page));
     $page = $paginator->getPaginate();
     $this->view->setVar("page", $page);
 }
开发者ID:ametsuramet,项目名称:eazy-dashboard,代码行数:7,代码来源:PostController.php

示例6: postContent

 public function postContent($type_id, $id = 'add')
 {
     $all = Input::all();
     if (!$all['slug']) {
         $all['slug'] = BaseController::ru2Lat($all['title']);
     }
     $rules = array('name' => 'required|min:2|max:255', 'title' => 'required|min:3|max:255', 'slug' => 'required|min:4|max:255|alpha_dash');
     $validator = Validator::make($all, $rules);
     if ($validator->fails()) {
         return Redirect::to('/admin/content/' . $type_id . '/' . $id)->withErrors($validator)->withInput()->with('error', 'Ошибка');
     }
     if (is_numeric($id)) {
         $post = Post::find($id);
     } else {
         $post = new Post();
     }
     $post->type_id = $all['type_id'];
     $post->name = $all['name'];
     $post->title = $all['title'];
     $post->slug = $all['slug'];
     $post->text = $all['text'];
     $post->parent = $all['parent'];
     $post->status = isset($all['status']) ? true : false;
     $post->order = $all['order'];
     $post->description = $all['description'];
     $post->keywords = $all['keywords'];
     if (isset($all['image'])) {
         $post->image = AdminController::saveImage($all['image'], 'upload/image/', 250);
     }
     $post->save();
     return Redirect::to('/admin/content/' . $all['type_id'] . '/' . $id)->with('success', 'Изменения сохранены');
 }
开发者ID:ldin,项目名称:project_kartinki,代码行数:32,代码来源:AdminController.php

示例7: updatePost

 public static function updatePost($input, $id)
 {
     $answer = [];
     $rules = ['title' => 'required', 'body' => 'required', 'user_id' => 'required|integer'];
     $validation = Validator::make($input, $rules);
     if ($validation->fails()) {
         $answer['message'] = $validation->errors()->getMessages();
         $answer['error'] = true;
     } else {
         $post = Post::find($id);
         $post->title = Input::get('title');
         $post->image_url = Input::get('image_url');
         $post->body = Input::get('body');
         $post->user_id = Input::get('user_id');
         if ($post->save()) {
             $answer['message'] = 'Editado con exito!';
             $answer['error'] = false;
             $answer['data'] = $post;
         } else {
             $answer['message'] = 'UPDATE error, team noob!';
             $answer['error'] = false;
         }
     }
     return $answer;
 }
开发者ID:hectorz11,项目名称:redaventura_example01,代码行数:25,代码来源:Post.php

示例8: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $post = Post::find($id);
     $post->delete();
     Session::flash('successMessage', 'Your post has been deleted.');
     return Redirect::action('posts.index');
 }
开发者ID:pascalallen,项目名称:tattoosbydrew.dev,代码行数:13,代码来源:PostsController.php

示例9: testTranslatedAttributesCanBeRetrievedInDifferentLocales

 public function testTranslatedAttributesCanBeRetrievedInDifferentLocales()
 {
     $this->createTwoPostsWithOneTranslatedInThreeLocales();
     $model = Post::find(1);
     $model->translations()->where('locale', 'en')->update(['title' => 'New Title']);
     $this->assertEquals('New Title', Post::find(1)->title);
 }
开发者ID:laraplus,项目名称:translatable,代码行数:7,代码来源:TestRelation.php

示例10: testPostKeywords

 public function testPostKeywords()
 {
     $post = Post::find(16);
     $this->assertTrue(count($post->keywords) > 0);
     $post = Post::find(2);
     $this->assertTrue(count($post->keywords) == 0);
 }
开发者ID:jgrossi,项目名称:corcel,代码行数:7,代码来源:TaxonomyTest.php

示例11: delete

 public function delete($id)
 {
     $post = $this->blogRepository->find($id);
     // Title
     $title = Lang::get('admin.blogs.title.blog_delete');
     // Show the page
     $this->render('admin.blogs.delete', compact('post', 'title'));
 }
开发者ID:christiannwamba,项目名称:laravel-site,代码行数:8,代码来源:AdminBlogsController.php

示例12: show

 public function show($id)
 {
     $post = Post::find($id);
     if ($post->is_premium && Auth::user()->stripe_plan != 'gold') {
         return View::make('error', ['message' => 'Only GOLD members can read this post, <a href="/upgrade">upgrade</a> your membership to get access']);
     }
     return View::make('post', ['post' => $post]);
 }
开发者ID:billwaddyjr,项目名称:laravelCashier,代码行数:8,代码来源:PostsController.php

示例13: testModelCanBeMassUpdated

 public function testModelCanBeMassUpdated()
 {
     Post::forceCreate(['id' => 1, 'title' => 'Lorem ipsum']);
     Post::forceCreate(['id' => 2, 'title' => 'Lorem ipsum']);
     Post::where('title', 'Lorem ipsum')->update(['title' => 'Lorem ipsum 2']);
     $this->assertEquals('Lorem ipsum 2', Post::find(1)->title);
     $this->assertEquals('Lorem ipsum 2', Post::find(2)->title);
 }
开发者ID:laraplus,项目名称:translatable,代码行数:8,代码来源:TestCRUD.php

示例14: getComments

 private function getComments()
 {
     $post = Post::find(Input::get('post'));
     if (is_null($post)) {
         return false;
     }
     return $post->comments()->where('created_at', '>', Input::get('timestamp'))->take($this->count)->get();
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:8,代码来源:LongPollController.php

示例15: setPostId

 /**
  * MI: Warning for Windows:
  * The PHP function symlink only works on Windows Vista, Server 2008 or greater.
  */
 public function setPostId($id)
 {
     $post = Post::find($id);
     $file = $post->file_path();
     symlink($file, $this->tempfile_image_path());
     $this->received_file = true;
     $this->md5 = $post->md5;
 }
开发者ID:JCQS04,项目名称:myimouto,代码行数:12,代码来源:InlineImage.php


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