Download the PHP package wp-kit/wordpress-eloquent without Composer
On this page you can find all versions of the php package wp-kit/wordpress-eloquent. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wp-kit/wordpress-eloquent
More information about wp-kit/wordpress-eloquent
Files in wp-kit/wordpress-eloquent
Package wordpress-eloquent
Short Description A Laravel wrapper for wordpress which turns all Wordpress models into Laravel Eloquent Models.
License MIT
Homepage https://github.com/drewjbartlett/wordpress-eloquent
Informations about the package wordpress-eloquent
Wordpress Laravel Eloquent Models
A library that converts converts wordpress tables into Laravel Eloquent Models. This is helpful for dropping into any wordpress project where maybe you'd rather use the awesome features of Laravel's Eloquent Models. Or maybe you're writing an API with something like Slim or better yet Lumen don't want to increase your load time by loading the entire WP core. This is a great boiler plate based off Eloquent by Laravel to get you going.
** This is documentation for additional functionality on top of Eloquent. For documentation on all of Eloquent's features you visit the documentation.
Overview
- Installation
- Setup
- Posts
- Comments
- Terms
- Users
- Meta
- Options
- Links
- Extending your own models
- Query Logs
Installation
composer require drewjbartlett/wordpress-eloquent
Setup
If you wanted to enable this on your entire WP install you could create a file with the above code to drop in the mu-plugins
folder.
Posts
Statuses
By default, the Post
returns posts with all statuses. You can however override this with the local scope published
to return only published posts.
Or if you need a specific status you can override with defined status via local scope.
Post Types
By default, the Post
returns posts with all post types. You can however override this by defining a post type via local scope.
Comments
Terms
In this version Term
is still accesible as a model but is only leveraged through posts.
Users
Meta
The models Post
, User
, Comment
, Term
, all implement the HasMeta
. Therefore they meta can easily be retrieved by the getMeta
and set by the setMeta
helper functions:
Options
In wordpress you can use get_option
. Alternatively, if you don't want to load the wordpress core you can use helper function getValue
.
Or of course, the long form:
Links
Extending your own models
If you want to add your own functionality to a model, for instance a User
you can do so like this:
Another example would be for custom taxonomies on a post, say country
Query Logs
Sometimes it's helpful to see the query logs for debugging. You can enable the logs by passing log
is set to true
(see setup) on the Laravel::connect
method. Logs are retrieved by running.