Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support laravel 5 #14

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
vendor
composer.lock
docs
build
build
.idea
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2

before_script:
- composer self-update
- composer install
- pyrus install pear/PHP_CodeSniffer
- pear install PHP_CodeSniffer
- phpenv rehash

script:
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# WordPressed

[![Build Status](https://travis-ci.org//square1-io/wordpressed.svg?branch=master)](https://travis-ci.org/square1-io/wordpressed)

Wordpressed - a simple ActiveRecord implementation for working with WordPress. Built on top of Laravels [Eloquent ORM](http://laravel.com/docs/eloquent).

Have a look at the [example usage](https://github.com/square1-io/wordpressed#example-usage) to figure out how to use it!
Expand All @@ -16,6 +18,16 @@ Via Composer
}
```

Version for Laravel 5

``` json
{
"require": {
"square1/wordpressed": "^0.1.8"
}
}
```

## Example Usage

``` php
Expand Down
12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,22 @@
"email": "ciaran@square1.io",
"homepage": "http://www.square1.io",
"role": "Developer"
},
{
"name": "Jose Vicente Orts Romero",
"email": "vince@square1.io",
"homepage": "http://www.square1.io",
"role": "Developer"
}
],
"require": {
"php": ">=5.4.0",
"illuminate/database": "4.2.*"
"illuminate/database": "4.2.*|5.*"
},
"require-dev": {
"squizlabs/php_codesniffer": "1.*",
"phpunit/phpunit": "4.1.*",
"mockery/mockery": "dev-master@dev"
"phpunit/phpunit": "^4.1",
"mockery/mockery": "^0.9"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions src/Attachment.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace Square1\Wordpressed;
<?php

use Square1\Wordpressed\Post as Post;
namespace Square1\Wordpressed;

class Attachment extends Post
{
Expand Down
18 changes: 9 additions & 9 deletions src/Category.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php namespace Square1\Wordpressed;
<?php

use Square1\Wordpressed\Term as Term;
namespace Square1\Wordpressed;

class Category extends Term
{
/**
* Override the default query to do all the category joins
* Override the default query to do all the category joins.
*
* @param boolean $excludeDeleted Include soft deleted columns
* @param bool $excludeDeleted Include soft deleted columns
*
* @return object The query object
* @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder The query object
*/
public function newQuery($excludeDeleted = true)
{
Expand All @@ -20,9 +20,9 @@ public function newQuery($excludeDeleted = true)
}

/**
* Return parent category
* Return parent category.
*
* @return
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function parents()
{
Expand All @@ -34,9 +34,9 @@ public function parents()
}

/**
* Return children categories
* Return children categories.
*
* @return
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function children()
{
Expand Down
18 changes: 10 additions & 8 deletions src/Comment.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php namespace Square1\Wordpressed;
<?php

namespace Square1\Wordpressed;

use Illuminate\Database\Eloquent\Model as Eloquent;

class Comment extends Eloquent
{
/**
/*
* Load MetaTrait
*/
use MetaTrait;
Expand All @@ -15,7 +17,7 @@ class Comment extends Eloquent
protected $table = 'comments';

/**
* @var string Primiary DB key
* @var string Primary DB key
*/
protected $primaryKey = 'comment_ID';

Expand All @@ -25,24 +27,24 @@ class Comment extends Eloquent
protected $with = ['meta'];

/**
* @var boolean Disable 'created_at' and 'updated_at' timestamp columns
* @var bool Disable 'created_at' and 'updated_at' timestamp columns
*/
public $timestamps = false;

/**
* Define user meta relationship
* Define user meta relationship.
*
* @return object
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function meta()
{
return $this->hasMany('Square1\Wordpressed\CommentMeta', 'comment_id');
}

/**
* Define post relationship
* Define post relationship.
*
* @return object
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function post()
{
Expand Down
17 changes: 9 additions & 8 deletions src/CommentMeta.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php namespace Square1\Wordpressed;
<?php

namespace Square1\Wordpressed;

use Illuminate\Database\Eloquent\Model as Eloquent;
use Square1\Wordpressed\MetaCollection as MetaCollection;

class CommentMeta extends Eloquent
{
Expand All @@ -11,31 +12,31 @@ class CommentMeta extends Eloquent
protected $table = 'commentmeta';

/**
* @var string Primiary DB key
* @var string Primary DB key
*/
protected $primaryKey = 'meta_id';

/**
* @var boolean Disable 'created_at' and 'updated_at' timestamp columns
* @var bool Disable 'created_at' and 'updated_at' timestamp columns
*/
public $timestamps = false;

/**
* Override the default Collection
* Override the default Collection.
*
* @param array $models
*
* @return \Square1\Wordpressed\UserMetaCollection
* @return \Square1\Wordpressed\MetaCollection
*/
public function newCollection(array $models = [])
{
return new MetaCollection($models);
}

/**
* Define user relationship
* Define user relationship.
*
* @return object
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function comment()
{
Expand Down
10 changes: 5 additions & 5 deletions src/Format.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php namespace Square1\Wordpressed;
<?php

use Square1\Wordpressed\Term as Term;
namespace Square1\Wordpressed;

class Format extends Term
{
/**
* Override the default query to do all the post format joins
* Override the default query to do all the post format joins.
*
* @param boolean $excludeDeleted Include soft deleted columns
* @param bool $excludeDeleted Include soft deleted columns
*
* @return object The query object
* @return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder
*/
public function newQuery($excludeDeleted = true)
{
Expand Down
28 changes: 15 additions & 13 deletions src/Manager.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
<?php namespace Square1\Wordpressed;
<?php

namespace Square1\Wordpressed;

use Illuminate\Database\Capsule\Manager as Capsule;

class Manager
{
/**
* @var Default database connection params
* @var array Default database connection params
*/
protected $config = [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'database',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'database',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => 'wp_',
'options' => [],
'prefix' => 'wp_',
'options' => [],
];

/**
* @var Illuminate\Database\Capsule\Manager
* @var \Illuminate\Database\Capsule\Manager
*/
private $capsule;

/**
* Connect to the Wordpress database
* Connect to the Wordpress database.
*
* @param array $config
*/
Expand All @@ -37,7 +39,7 @@ public function __construct(array $config = [])
}

/**
* Get the query log
* Get the query log.
*
* @return array
*/
Expand Down
8 changes: 6 additions & 2 deletions src/MetaCollection.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php namespace Square1\Wordpressed;
<?php

namespace Square1\Wordpressed;

use Illuminate\Database\Eloquent\Collection;

class MetaCollection extends Collection
{
/**
* Return value for the given key
* Return value for the given key.
*
* @param string $key
*
Expand All @@ -18,5 +20,7 @@ public function __get($key)
return $item->meta_value;
}
}

return null;
}
}
6 changes: 4 additions & 2 deletions src/MetaTrait.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php namespace Square1\Wordpressed;
<?php

namespace Square1\Wordpressed;

trait MetaTrait
{
/**
* Return meta value from parent object via a magic method
* Return meta value from parent object via a magic method.
*
* @param string $key
*
Expand Down
5 changes: 3 additions & 2 deletions src/Option.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php namespace Square1\Wordpressed;
<?php

namespace Square1\Wordpressed;

use Illuminate\Database\Eloquent\Model as Eloquent;

class Option extends Eloquent
{

}
4 changes: 2 additions & 2 deletions src/Page.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace Square1\Wordpressed;
<?php

use Square1\Wordpressed\Post as Post;
namespace Square1\Wordpressed;

class Page extends Post
{
Expand Down
Loading