{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/11617","labels_url":"https://api.github.com/repos/laravel/framework/issues/11617/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/11617/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/11617/events","html_url":"https://github.com/laravel/framework/pull/11617","id":124288882,"number":11617,"title":"[5.2] TokenGuard missing column 'api_token' (storageKey)","user":{"login":"ChristianChoi","id":2939663,"avatar_url":"https://avatars.githubusercontent.com/u/2939663?v=3","gravatar_id":"","url":"https://api.github.com/users/ChristianChoi","html_url":"https://github.com/ChristianChoi","followers_url":"https://api.github.com/users/ChristianChoi/followers","following_url":"https://api.github.com/users/ChristianChoi/following{/other_user}","gists_url":"https://api.github.com/users/ChristianChoi/gists{/gist_id}","starred_url":"https://api.github.com/users/ChristianChoi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChristianChoi/subscriptions","organizations_url":"https://api.github.com/users/ChristianChoi/orgs","repos_url":"https://api.github.com/users/ChristianChoi/repos","events_url":"https://api.github.com/users/ChristianChoi/events{/privacy}","received_events_url":"https://api.github.com/users/ChristianChoi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-12-30T00:56:11Z","updated_at":"2015-12-30T01:59:26Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/laravel/framework/pulls/11617","html_url":"https://github.com/laravel/framework/pull/11617","diff_url":"https://github.com/laravel/framework/pull/11617.diff","patch_url":"https://github.com/laravel/framework/pull/11617.patch"},"body":"When trying to use the middleware '**auth:api**' on a fresh 5.2 project, the TokenGuard is performing the following SQL query (example):\r\n```sql\r\nselect * from `users` where `api_token` = uDn2LP7IWO limit 1\r\n-- error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'api_token' in 'where clause' \r\n```\r\nHowever the column '**api_token**' is missing from the 'users' table, unless manually added.\r\n\r\nI suggest we add helper methods to add/drop this column to the Blueprint, in the same way we add the 'remember_token' column, so we can do something like this:\r\n```php\r\npublic function up()\r\n{\r\n    Schema::create('users', function (Blueprint $table) {\r\n        $table->increments('id');\r\n        $table->string('name');\r\n        $table->string('email')->unique();\r\n        $table->string('password', 60);\r\n        $table->rememberToken();\r\n        $table->apiToken();\r\n        $table->timestamps();\r\n    });\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/167917174","html_url":"https://github.com/laravel/framework/pull/11617#issuecomment-167917174","issue_url":"https://api.github.com/repos/laravel/framework/issues/11617","id":167917174,"user":{"login":"ChristianChoi","id":2939663,"avatar_url":"https://avatars.githubusercontent.com/u/2939663?v=3","gravatar_id":"","url":"https://api.github.com/users/ChristianChoi","html_url":"https://github.com/ChristianChoi","followers_url":"https://api.github.com/users/ChristianChoi/followers","following_url":"https://api.github.com/users/ChristianChoi/following{/other_user}","gists_url":"https://api.github.com/users/ChristianChoi/gists{/gist_id}","starred_url":"https://api.github.com/users/ChristianChoi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChristianChoi/subscriptions","organizations_url":"https://api.github.com/users/ChristianChoi/orgs","repos_url":"https://api.github.com/users/ChristianChoi/repos","events_url":"https://api.github.com/users/ChristianChoi/events{/privacy}","received_events_url":"https://api.github.com/users/ChristianChoi/received_events","type":"User","site_admin":false},"created_at":"2015-12-30T01:59:25Z","updated_at":"2015-12-30T01:59:25Z","body":"I suppose you're right, when viewing this PR on it's own. It'd have to be used in conjunction with updates to either the user migration file or the docs, so people would know these methods exists.\r\nBut of course simply updating the docs to mention, that an '**api_token**' column is required to use the **auth:api** middleware would be sufficient.\r\nAnyhow; I still like these methods, which is why my first thought was to make a PR with them."}}