{"id":15150796,"url":"https://github.com/quentingab/wodel","last_synced_at":"2025-09-29T20:31:11.395Z","repository":{"id":62532097,"uuid":"279638912","full_name":"QuentinGab/Wodel","owner":"QuentinGab","description":"WordPress Post Model. Eloquent like syntax with wp database function.","archived":true,"fork":false,"pushed_at":"2021-09-05T03:38:14.000Z","size":112,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-12-15T12:47:03.447Z","etag":null,"topics":["eloquent","model","models","wordpress","wordpress-development"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/QuentinGab.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-14T16:34:03.000Z","updated_at":"2024-05-24T10:59:58.000Z","dependencies_parsed_at":"2022-11-02T14:32:42.477Z","dependency_job_id":null,"html_url":"https://github.com/QuentinGab/Wodel","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuentinGab%2FWodel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuentinGab%2FWodel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuentinGab%2FWodel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuentinGab%2FWodel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QuentinGab","download_url":"https://codeload.github.com/QuentinGab/Wodel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234659864,"owners_count":18867630,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eloquent","model","models","wordpress","wordpress-development"],"created_at":"2024-09-26T14:42:39.194Z","updated_at":"2025-09-29T20:31:06.107Z","avatar_url":"https://github.com/QuentinGab.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wodel\nEasy way to interact with WordPress database, query, insert and update posts.\nAnd it also works with ACF.\n\n[![Latest Version on Packagist][ico-version]](https://packagist.org/packages/quentingab/wodel)\n[![Software License][ico-license]](LICENSE.md)\n[![Total Downloads][ico-downloads]](https://packagist.org/packages/quentingab/wodel)\n\n\u003c!-- [![Build Status][ico-travis]][link-travis] --\u003e\n\u003c!-- [![Coverage Status][ico-scrutinizer]][link-scrutinizer] --\u003e\n\u003c!-- [![Quality Score][ico-code-quality]][link-code-quality] --\u003e\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require quentingab/wodel\n```\n\n## Usage with WordPress posts\n\n### Get all posts/page and custom post type\n``` php\n$posts = QuentinGgab\\Models\\Wodel::all();\nforeach($posts as $post){\n    echo $post-\u003epost_title;\n}\n```\n### Get current post with acf\n``` php\n$post = QuentinGab\\Models\\Wodel::current();\n```\n\n### Update a post\n``` php\n$post = QuentinGab\\Models\\Wodel::current();\n$post-\u003epost_title = \"Hello World\";\n$post-\u003esave();\n```\n\n### Insert a post\n``` php\n$post = new QuentinGab\\Models\\Wodel(\n    [\n    'post_title'=\u003e'Hello World'\n    ]\n);\n$post-\u003esave();\n```\n\n## Extend the Wodel\n``` php\nclass Page extends QuentinGab\\Wodel\\Models\\Wodel\n{\n    protected $post_type = 'page';\n    \n    //only necessary if you want to insert a new post programmatically\n    //otherwise the acf fields will not be populated\n    //If you only get Model or update existing Model you can omit $acf_keys\n    protected $acf_keys = [\n        'the_field_name' =\u003e 'the_field_key',\n        'color' =\u003e 'field_5f7848684c404',\n    ];\n}\n\n$page = Page::find(1);\necho $page-\u003ecolor;\n```\n\n\n## Usage with custom table\nif you have data stored in a custom table you can use QuentinGab\\Models\\Model to interact with the database.\nUnder the hood it only use default WordPress object $wpdb.\n\n### Example of a custom table\n``` php\nglobal $wpdb;\n\n$table_name = 'events';\n$charset_collate = $wpdb-\u003eget_charset_collate();\n\n$sql = \"CREATE TABLE $table_name (\n    id bigint(20) NOT NULL AUTO_INCREMENT,\n    title varchar(255),\n    active boolean DEFAULT 0 NOT NULL,\n    created_at datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,\n    PRIMARY KEY  (id)\n) $charset_collate;\";\n\ndbDelta($sql);\n```\n### Create a Model class\n``` php\nclass Event extends QuentinGab\\Wodel\\Models\\Model\n{\n    protected $table = 'events';\n    \n    protected $primary_key = \"id\";\n    \n    protected $fillable = [\n        'title'\n    ];\n\n    protected $casts = [\n        'active' =\u003e 'bool',\n    ];\n}\n```\n### Get Model\n``` php\n$all = Event::all();\n$only_active = Event::where(['active'=\u003etrue]);\n$with_primary_key_1 = Event::find(1);\n```\n### Save Model\n``` php\n$new_event = new Event(['title'=\u003e'my new event','active'=\u003efalse]);\n$new_event-\u003esave();\n```\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email quentin.gabriele@gmail.com instead of using the issue tracker.\n\n## Credits\n\n- [quentin gabriele](https://github.com/QuentinGab)\n\u003c!-- - [All Contributors][link-contributors] --\u003e\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/quentingab/wodel.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/quentingab/wodel/master.svg?style=flat-square\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/quentingab/wodel.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/quentingab/wodel.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/quentingab/wodel.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/quentingab/wodel\n[link-travis]: https://travis-ci.org/quentingab/wodel\n[link-scrutinizer]: https://scrutinizer-ci.com/g/quentingab/wodel/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/quentingab/wodel\n[link-downloads]: https://packagist.org/packages/quentingab/wodel\n[link-author]: https://github.com/quentingab\n[link-contributors]: ../../contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquentingab%2Fwodel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquentingab%2Fwodel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquentingab%2Fwodel/lists"}