/**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     WP::setContainer($this->app);
     $this->registerPostBuilder();
     $this->registerTermBuilder();
     $this->app->singleton('wp', function () {
         return new WP();
     });
 }
示例#2
0
 /**
  * Create a new query instance.
  *
  * @param \Luminous\Bridge\WP $wp
  * @param \Illuminate\Http\Request $request
  * @return void
  *
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  */
 public function __construct(WP $wp, Request $request)
 {
     $this->wp = $wp;
     $this->request = $request;
     $this->postType = $this->wp->postType($this->route('post_type'));
 }
示例#3
0
文件: Type.php 项目: hrslash/luminous
 /**
  * Get the post type.
  *
  * @return \Luminous\Bridge\Post\Type
  */
 protected function getPostTypeAttribute()
 {
     $postType = $this->original->object_type[0];
     return WP::postType($postType);
 }
示例#4
0
 /**
  * Create a new date archive instance from a specific format.
  *
  * @param string $type
  * @param string $format
  * @param string $value
  * @param bool $local
  * @return static
  */
 public static function createFromFormat($type, $format, $value, $local = true)
 {
     $timezone = $local ? WP::timezone() : null;
     $datetime = Carbon::createFromFormat($format, $value, $timezone);
     return new static($type, $datetime->startOfDay());
 }
示例#5
0
 /**
  * Get the children.
  *
  * @return \Luminous\Bridge\Post\Query\Builder
  */
 protected function getChildrenAttribute()
 {
     return WP::posts($this->type)->wherePost('parent_id', $this->id);
 }
示例#6
0
 /**
  * Get the children.
  *
  * @param bool $direct
  * @return \Luminous\Bridge\Term\Query\Builder
  */
 public function children($direct = true)
 {
     $column = $direct ? 'parent_id' : 'ancestor_id';
     return WP::terms($this->type)->whereTerm($column, $this->id);
 }
 /**
  * Get the older post.
  *
  * @return \Luminous\Bridge\Post\Entity|null
  */
 public function getOlderAttribute()
 {
     return WP::posts($this->type)->whereDate('created_at', '<', $this->created_at)->orderBy('created_at', 'desc')->first();
 }