tareq1988 / wp-eloquent

Eloquent ORM for WordPress
https://tareq.co/2015/05/eloquent-orm-in-wordpress/
566 stars 135 forks source link

is there anyway to add new model? #10

Closed iwillhappy1314 closed 8 years ago

iwillhappy1314 commented 8 years ago

the example code use the default WordPress data model, is there anyway to add new model?

dreanmer commented 8 years ago

take a look at readme:

Writing a Model

use \WeDevs\ORM\Eloquent\Model as Model;

class Employee extends Model {

}

var_dump( Employee::all()->toArray() ); // gets all employees
var_dump( Employee::find(1) ); // find employee with ID 1

The class name Employee will be translated into PREFIX_employees table to run queries. But as usual, you can override the table name.

here is more info for Eloquent: https://laravel.com/docs/5.1/eloquent

iwillhappy1314 commented 8 years ago

@Dreanmer thanks a lot, got it.