/** * 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(); }); }
/** * 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')); }
/** * Get the post type. * * @return \Luminous\Bridge\Post\Type */ protected function getPostTypeAttribute() { $postType = $this->original->object_type[0]; return WP::postType($postType); }
/** * 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()); }
/** * Get the children. * * @return \Luminous\Bridge\Post\Query\Builder */ protected function getChildrenAttribute() { return WP::posts($this->type)->wherePost('parent_id', $this->id); }
/** * 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(); }