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


PHP Post::first方法代码示例

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


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

示例1: testFirst

 public function testFirst()
 {
     $post = Post::first();
     $debug = last(DB::getQueryLog());
     $this->assertEquals('Bar', $post->title);
     $this->assertEquals('select * from "posts" where "published" = ? and "status" = ? limit 1', $debug['query']);
 }
开发者ID:pixelpeter,项目名称:eloquent-filterable,代码行数:7,代码来源:EloquentFilterTest.php

示例2: run

 public function run()
 {
     DB::table('comments')->delete();
     $user_id = User::first()->id;
     $post_id = Post::first()->id;
     DB::table('comments')->insert(array(array('user_id' => $user_id, 'post_id' => $post_id, 'content' => $this->content1, 'created_at' => new DateTime(), 'updated_at' => new DateTime()), array('user_id' => $user_id, 'post_id' => $post_id, 'content' => $this->content2, 'created_at' => new DateTime(), 'updated_at' => new DateTime()), array('user_id' => $user_id, 'post_id' => $post_id, 'content' => $this->content3, 'created_at' => new DateTime(), 'updated_at' => new DateTime()), array('user_id' => $user_id, 'post_id' => $post_id + 1, 'content' => $this->content1, 'created_at' => new DateTime(), 'updated_at' => new DateTime()), array('user_id' => $user_id, 'post_id' => $post_id + 1, 'content' => $this->content2, 'created_at' => new DateTime(), 'updated_at' => new DateTime()), array('user_id' => $user_id, 'post_id' => $post_id + 2, 'content' => $this->content1, 'created_at' => new DateTime(), 'updated_at' => new DateTime())));
 }
开发者ID:ntk148v,项目名称:mini_cms,代码行数:7,代码来源:CommentsTableSeeder.php

示例3: run

 public function run()
 {
     DB::table('comments')->delete();
     $user_id = User::first()->id;
     $post_id = Post::first()->id;
     DB::table('comments')->insert(array(array('user_id' => $user_id, 'post_id' => $post_id, 'content' => $this->content1), array('user_id' => $user_id, 'post_id' => $post_id, 'content' => $this->content2), array('user_id' => $user_id, 'post_id' => $post_id, 'content' => $this->content3), array('user_id' => $user_id, 'post_id' => $post_id + 1, 'content' => $this->content1), array('user_id' => $user_id, 'post_id' => $post_id + 1, 'content' => $this->content2), array('user_id' => $user_id, 'post_id' => $post_id + 2, 'content' => $this->content1)));
 }
开发者ID:hilmysyarif,项目名称:l4-bootstrap-admin,代码行数:7,代码来源:CommentsTableSeeder.php

示例4: indexAction

 public function indexAction($sub)
 {
     App::setLocale("en");
     if (Input::get("lang") === "nl") {
         App::setLocale("nl");
     }
     return View::make("index/index", ["post" => Post::first()]);
 }
开发者ID:fajars87,项目名称:tutorial-laravel-4-multisites,代码行数:8,代码来源:IndexController.php

示例5: testSyncInManyToManyRelationship

 public function testSyncInManyToManyRelationship()
 {
     $post = Post::forceCreate(['title' => 'Post title']);
     $tag = Tag::forceCreate(['title' => 'Tag title']);
     $post->tags()->sync([$tag->id]);
     $this->assertEquals(1, Post::first()->tags->count());
     $this->assertEquals('Tag title', Post::first()->tags()->first()->title);
 }
开发者ID:laraplus,项目名称:translatable,代码行数:8,代码来源:TestRelation.php

示例6: myaccount

 public function myaccount($s = "user")
 {
     $view = $this->getActionView();
     if (RequestMethods::post('delete')) {
         $del = Post::first(array('id = ?' => RequestMethods::post('id')));
         $del->delete();
     }
     if (RequestMethods::post('block')) {
         $block = User::first(array("id = ?" => RequestMethods::post('id')));
         $block->live = 0;
         $block->save();
     }
     if (RequestMethods::post('unblock')) {
         $block = User::first(array("id = ?" => RequestMethods::post('id')));
         $block->live = 1;
         $block->save();
     }
     if (isset($this->_user)) {
         $admin = User::first(array("admin = ?" => '1', "id = ?" => $this->user->id));
         if (!empty($admin)) {
             if ($s != 'post') {
                 $admin_table = $s::all();
             }
             if ($s == 'post') {
                 $database = Registry::get("database");
                 $conn = $database->initialize();
                 $admin_table = $conn->query()->from('posts')->join("users", "posts.from_user = users.id")->all();
             }
             $view->set("admin_table", $admin_table);
         } else {
             $posts = Post::all(array("from_user = ?" => $this->user->id));
             $view->set("posts", $posts);
         }
         $view->set("admin", $admin)->set('table', $s);
     }
 }
开发者ID:shreyanshgoel,项目名称:blog,代码行数:36,代码来源:users.php

示例7: testNonStaticCallOfFindBySlug

 /**
  * Test Non static call for findBySlug is working
  *
  * @test
  */
 public function testNonStaticCallOfFindBySlug()
 {
     $post1 = $this->makePost('My first post');
     $post1->save();
     $post = Post::first();
     $resultId = $post->findBySlug('my-first-post')->id;
     $this->assertEquals($post1->id, $resultId);
 }
开发者ID:ChrisReid,项目名称:eloquent-sluggable,代码行数:13,代码来源:SluggableTest.php

示例8: testDeleteWithoutTranslations

 public function testDeleteWithoutTranslations()
 {
     Post::forceCreate(['title' => 'Title']);
     Post::i18nQuery()->truncate();
     $post = Post::first();
     $post->delete();
     $this->assertCount(0, Post::all());
 }
开发者ID:laraplus,项目名称:translatable,代码行数:8,代码来源:TestCRUD.php

示例9: it_fetches_the_cover_associated_with_the_post

 /** @test **/
 public function it_fetches_the_cover_associated_with_the_post()
 {
     $this->createComponent('posts');
     $this->createComponent('cover_photos');
     $this->insertOn('posts', ['title' => 'Random Blog Post']);
     $this->insertOn('cover_photos', ['image' => '/path/to/image.jpg']);
     Post::usesOne(CoverPhoto::class);
     CoverPhoto::first()->registerTo(Post::first());
     $cover = Post::first()->cover_photo;
     $this->assertEquals('/path/to/image.jpg', $cover->image);
 }
开发者ID:typecms,项目名称:core,代码行数:12,代码来源:ComponentModelTest.php

示例10: var_dump

<?php

/**
 * Copyright (c) 2014 Keith Casey.
 *
 * This code is designed to accompany the lynda.com video course "Design Patterns in PHP"
 *   by Keith Casey. If you've received this code without seeing the videos, go watch the
 *   videos. It will make way more sense and be more useful in general.
 */
include_once __DIR__ . '/vendor/autoload.php';
include_once 'posts.php';
echo "<pre style='color:#59E817; background-color:black; word-wrap:break-word;'>";
var_dump(Post::first());
echo '</pre>';
// $post = new Post();
//
// $post->title = 'Sample Title';
// $post->body = 'This is the body';
//
// $post->save();
开发者ID:matteo-hertel,项目名称:archive,代码行数:20,代码来源:index.php

示例11: testBootMethodAgainAndAgain

 public function testBootMethodAgainAndAgain()
 {
     Post::create(['comments_count' => 2]);
     $this->assertEquals(1, Post::count());
     $this->assertEquals(6, Post::first()->comments_count);
 }
开发者ID:Grafikart,项目名称:liferaft,代码行数:6,代码来源:PostTest.php


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