/** * filter */ public function filter() { $user = User::where('api_token', Request::header(static::APPLICATION_TOKEN))->first(); if (is_null($user)) { return Response::json(['message' => '401 Unauthorized'], 401); } app()[static::AUTHORIZED_USER] = $user; return null; }
/** * */ public function run() { Reservation::truncateWithIgnoreForeignKeyChecks(); Book::truncateWithIgnoreForeignKeyChecks(); User::truncateWithIgnoreForeignKeyChecks(); DB::table('users')->insert([['id' => 1, 'api_token' => 'token1', 'name' => '氏名1'], ['id' => 2, 'api_token' => 'token2', 'name' => '氏名2']]); DB::table('books')->insert([['id' => 1, 'asin' => 'asin1', 'title' => '書籍1', 'price' => 1000, 'inventory' => 10]]); DB::table('reservations')->insert([['id' => 1, 'user_id' => 1, 'book_id' => 1, 'quantity' => 1, 'reservation_code' => 'code1'], ['id' => 2, 'user_id' => 1, 'book_id' => 1, 'quantity' => 2, 'reservation_code' => 'code2'], ['id' => 3, 'user_id' => 2, 'book_id' => 1, 'quantity' => 1, 'reservation_code' => 'code3']]); }
/** * */ public function run() { User::truncateWithIgnoreForeignKeyChecks(); DB::table('users')->insert(['id' => 1, 'api_token' => 'token1', 'name' => '氏名1']); }