{"action":"created","issue":{"url":"https://api.github.com/repos/jgrossi/corcel/issues/77","repository_url":"https://api.github.com/repos/jgrossi/corcel","labels_url":"https://api.github.com/repos/jgrossi/corcel/issues/77/labels{/name}","comments_url":"https://api.github.com/repos/jgrossi/corcel/issues/77/comments","events_url":"https://api.github.com/repos/jgrossi/corcel/issues/77/events","html_url":"https://github.com/jgrossi/corcel/issues/77","id":136984918,"number":77,"title":"Laravel / Corcel ignoring $connection set in model","user":{"login":"DeanWard","id":397670,"avatar_url":"https://avatars.githubusercontent.com/u/397670?v=3","gravatar_id":"","url":"https://api.github.com/users/DeanWard","html_url":"https://github.com/DeanWard","followers_url":"https://api.github.com/users/DeanWard/followers","following_url":"https://api.github.com/users/DeanWard/following{/other_user}","gists_url":"https://api.github.com/users/DeanWard/gists{/gist_id}","starred_url":"https://api.github.com/users/DeanWard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DeanWard/subscriptions","organizations_url":"https://api.github.com/users/DeanWard/orgs","repos_url":"https://api.github.com/users/DeanWard/repos","events_url":"https://api.github.com/users/DeanWard/events{/privacy}","received_events_url":"https://api.github.com/users/DeanWard/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jgrossi/corcel/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-02-28T00:12:29Z","updated_at":"2016-03-26T14:20:32Z","closed_at":null,"body":"I've added a Post model to my app directory that looks like this\r\n\r\n    <?php\r\n\r\n    namespace App;\r\n\r\n    use Corcel\\Post as Corcel;\r\n\r\n    class Post extends Corcel\r\n    {\r\n        protected $connection = 'wordpress';\r\n    }\r\n\r\nI've added a custom connection to my database.php file:\r\n\r\n    'wordpress' => [\r\n        'driver'    => 'mysql',\r\n        'host'      => env('DB_HOST', ''),\r\n        'database'  => env('DB_DATABASE', ''),\r\n        'username'  => env('DB_USERNAME', ''),\r\n        'password'  => env('DB_PASSWORD', ''),\r\n        'charset'   => 'utf8',\r\n        'collation' => 'utf8_unicode_ci',\r\n        'prefix'    => 'wp_',\r\n        'strict'    => false,\r\n        'engine'    => null,\r\n    ],    \r\n\r\nYet when requesting posts like so:\r\n\r\n    $posts = App\\Post::all();\r\n\r\nI'm getting an error because it's using the wrong connection and not adding the wp_ prefix.\r\n\r\n    SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cms.terms' doesn't exist (SQL: select * from `terms` where `terms`.`term_id` in (1))\r\n\r\nThanks for the awesome work you're all doing on this!"},"comment":{"url":"https://api.github.com/repos/jgrossi/corcel/issues/comments/201832377","html_url":"https://github.com/jgrossi/corcel/issues/77#issuecomment-201832377","issue_url":"https://api.github.com/repos/jgrossi/corcel/issues/77","id":201832377,"user":{"login":"vgomes","id":4998838,"avatar_url":"https://avatars.githubusercontent.com/u/4998838?v=3","gravatar_id":"","url":"https://api.github.com/users/vgomes","html_url":"https://github.com/vgomes","followers_url":"https://api.github.com/users/vgomes/followers","following_url":"https://api.github.com/users/vgomes/following{/other_user}","gists_url":"https://api.github.com/users/vgomes/gists{/gist_id}","starred_url":"https://api.github.com/users/vgomes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vgomes/subscriptions","organizations_url":"https://api.github.com/users/vgomes/orgs","repos_url":"https://api.github.com/users/vgomes/repos","events_url":"https://api.github.com/users/vgomes/events{/privacy}","received_events_url":"https://api.github.com/users/vgomes/received_events","type":"User","site_admin":false},"created_at":"2016-03-26T14:20:32Z","updated_at":"2016-03-26T14:20:32Z","body":"Using 1.0.3 keeps happening.\r\n\r\nI've defined my connection as \r\n`'wordpress' => [ // this is your Corcel database connection, where WordPress tables are\r\n            'driver' => 'mysql',\r\n            'host' => env('DB_HOST', 'localhost'),\r\n            'port' => env('DB_PORT', '3306'),\r\n            'database' => env('DB_DATABASE', 'forge'),\r\n            'username' => env('DB_USERNAME', 'forge'),\r\n            'password' => env('DB_PASSWORD', ''),\r\n            'charset' => 'utf8',\r\n            'collation' => 'utf8_unicode_ci',\r\n            'prefix' => 'wp_',\r\n            'strict' => false,\r\n            'engine' => null,\r\n        ],`\r\n\r\nand my Post model as\r\n`<?php\r\n\r\nnamespace App;\r\n\r\nclass Post extends \\Corcel\\Post\r\n{\r\n    protected $connection = 'wordpress';\r\n}`\r\n\r\nbut when I'm trying to do a simple `$posts = Post::published()->get();` I get an error `Base table or view not found: 1146 Table 'bar.postmeta' doesn't exist`\r\n\r\nIf I put the **protected $connection = 'wordpress';** into the file **vendor/jgrossi/corcel/src/Model.php**, all seems to work properly, but I assume that after a **composer update** this change could be potentially gone."}}