From 7575738f13952941953e355e286fa1fae9d7908c Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 25 Aug 2020 11:31:22 +0900 Subject: [PATCH 001/132] feat: create reservations table migration --- ...08_25_021722_create_reservations_table.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 database/migrations/2020_08_25_021722_create_reservations_table.php diff --git a/database/migrations/2020_08_25_021722_create_reservations_table.php b/database/migrations/2020_08_25_021722_create_reservations_table.php new file mode 100644 index 00000000..e3943cef --- /dev/null +++ b/database/migrations/2020_08_25_021722_create_reservations_table.php @@ -0,0 +1,38 @@ +string('id'); + $table->primary('id'); + $table->string('email'); + $table->integer('people_count'); + $table->string('time_id'); + $table->string('name'); + $table->string('address'); + $table->string('cellphone'); + $table->string('guest_id'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('reservations'); + } +} From 2ef93f0a4c6bea3c05120a7d6657307d3d94c222 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 25 Aug 2020 11:49:50 +0900 Subject: [PATCH 002/132] feat: create guests table migration --- .../2020_08_25_023544_create_guests_table.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 database/migrations/2020_08_25_023544_create_guests_table.php diff --git a/database/migrations/2020_08_25_023544_create_guests_table.php b/database/migrations/2020_08_25_023544_create_guests_table.php new file mode 100644 index 00000000..54b4fad6 --- /dev/null +++ b/database/migrations/2020_08_25_023544_create_guests_table.php @@ -0,0 +1,37 @@ +string('id'); + $table->primary('id'); + $table->timestamp('entered_at')->useCurrent(); + $table->timestamp('exit_scheduled_at'); + $table->timestamp('exited_at')->nullable(); + $table->string('reservation_id'); + $table->string('exh_id')->nullable(); + $table->string('term_id'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('guests'); + } +} From 09cd76c55cbd512f64336317fae5432d74663bc6 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 25 Aug 2020 11:50:12 +0900 Subject: [PATCH 003/132] feat: create activity_logs table migration --- ...8_25_024543_create_activity_logs_table.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 database/migrations/2020_08_25_024543_create_activity_logs_table.php diff --git a/database/migrations/2020_08_25_024543_create_activity_logs_table.php b/database/migrations/2020_08_25_024543_create_activity_logs_table.php new file mode 100644 index 00000000..e9f84068 --- /dev/null +++ b/database/migrations/2020_08_25_024543_create_activity_logs_table.php @@ -0,0 +1,34 @@ +bigIncrements('id'); + $table->timestamp('timestamp')->useCurrent(); + $table->string('exh_id'); + $table->string('guest_id'); + $table->string('log_type'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('activity_logs'); + } +} From f6af791ce42a7c1964a9b395991ccf958652b729 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Fri, 28 Aug 2020 09:59:18 +0900 Subject: [PATCH 004/132] fix: to follow new doccument from afes-website/docs --- .../migrations/2020_08_25_021722_create_reservations_table.php | 2 +- database/migrations/2020_08_25_023544_create_guests_table.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/database/migrations/2020_08_25_021722_create_reservations_table.php b/database/migrations/2020_08_25_021722_create_reservations_table.php index e3943cef..70e3d18e 100644 --- a/database/migrations/2020_08_25_021722_create_reservations_table.php +++ b/database/migrations/2020_08_25_021722_create_reservations_table.php @@ -18,7 +18,7 @@ public function up() $table->primary('id'); $table->string('email'); $table->integer('people_count'); - $table->string('time_id'); + $table->string('term_id'); $table->string('name'); $table->string('address'); $table->string('cellphone'); diff --git a/database/migrations/2020_08_25_023544_create_guests_table.php b/database/migrations/2020_08_25_023544_create_guests_table.php index 54b4fad6..4abff4a6 100644 --- a/database/migrations/2020_08_25_023544_create_guests_table.php +++ b/database/migrations/2020_08_25_023544_create_guests_table.php @@ -17,7 +17,6 @@ public function up() $table->string('id'); $table->primary('id'); $table->timestamp('entered_at')->useCurrent(); - $table->timestamp('exit_scheduled_at'); $table->timestamp('exited_at')->nullable(); $table->string('reservation_id'); $table->string('exh_id')->nullable(); From e1f094b9ce7d043b7ef4deff6914b5ef8d88181b Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Fri, 28 Aug 2020 10:06:09 +0900 Subject: [PATCH 005/132] feat: create terms migration --- .../2020_08_25_111818_create_terms_table.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 database/migrations/2020_08_25_111818_create_terms_table.php diff --git a/database/migrations/2020_08_25_111818_create_terms_table.php b/database/migrations/2020_08_25_111818_create_terms_table.php new file mode 100644 index 00000000..6e65d452 --- /dev/null +++ b/database/migrations/2020_08_25_111818_create_terms_table.php @@ -0,0 +1,34 @@ +string('id'); + $table->primary('id'); + $table->timestamp('enter_scheduled_time'); + $table->timestamp('exit_scheduled_time'); + $table->string('color_id'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('terms'); + } +} From 1ca1817b3945c253a07e889a7ec7bf57cce956e4 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Fri, 28 Aug 2020 14:43:46 +0900 Subject: [PATCH 006/132] feat: add 4 models --- app/Models/ActivityLog.php | 47 ++++++++++++++++++++++++++++++++ app/Models/Guest.php | 55 ++++++++++++++++++++++++++++++++++++++ app/Models/Reservation.php | 46 +++++++++++++++++++++++++++++++ app/Models/Term.php | 38 ++++++++++++++++++++++++++ 4 files changed, 186 insertions(+) create mode 100644 app/Models/ActivityLog.php create mode 100644 app/Models/Guest.php create mode 100644 app/Models/Reservation.php create mode 100644 app/Models/Term.php diff --git a/app/Models/ActivityLog.php b/app/Models/ActivityLog.php new file mode 100644 index 00000000..7e79b124 --- /dev/null +++ b/app/Models/ActivityLog.php @@ -0,0 +1,47 @@ +belongsTo('\App\Models\Guest'); + } + +} diff --git a/app/Models/Guest.php b/app/Models/Guest.php new file mode 100644 index 00000000..f68654b8 --- /dev/null +++ b/app/Models/Guest.php @@ -0,0 +1,55 @@ +belongsTo('\App\Models\Reservation'); + } + + public function logs() { + return $this->hasMany('\App\Models\ActivityLog'); + } + + public function term() { + return $this->belongsTo('\App\Models\Term'); + } + +} diff --git a/app/Models/Reservation.php b/app/Models/Reservation.php new file mode 100644 index 00000000..60a04d0f --- /dev/null +++ b/app/Models/Reservation.php @@ -0,0 +1,46 @@ +belongsTo('\App\Models\Guest'); + } + + public function term() { + return $this->belongsTo('\App\Models\Term'); + } +} diff --git a/app/Models/Term.php b/app/Models/Term.php new file mode 100644 index 00000000..cca2abdd --- /dev/null +++ b/app/Models/Term.php @@ -0,0 +1,38 @@ + Date: Sat, 29 Aug 2020 15:29:42 +0900 Subject: [PATCH 007/132] fix: reservation model and reservation migration --- app/Models/Reservation.php | 2 +- .../migrations/2020_08_25_021722_create_reservations_table.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/Reservation.php b/app/Models/Reservation.php index 60a04d0f..bea8ddea 100644 --- a/app/Models/Reservation.php +++ b/app/Models/Reservation.php @@ -18,7 +18,7 @@ class Reservation extends Model implements AuthenticatableContract, Authorizable * @var array */ protected $fillable = [ - 'id', 'people_count', 'term_id', 'email', 'address', 'cell_phone', 'guest_id' + 'id', 'people_count', 'name', 'term_id', 'email', 'address', 'cellphone', 'guest_id', ]; /** diff --git a/database/migrations/2020_08_25_021722_create_reservations_table.php b/database/migrations/2020_08_25_021722_create_reservations_table.php index 70e3d18e..c0e8e262 100644 --- a/database/migrations/2020_08_25_021722_create_reservations_table.php +++ b/database/migrations/2020_08_25_021722_create_reservations_table.php @@ -22,7 +22,7 @@ public function up() $table->string('name'); $table->string('address'); $table->string('cellphone'); - $table->string('guest_id'); + $table->string('guest_id')->nullable(); }); } From 62f3f203dcacfe3610578a0909db536385db7724 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 29 Aug 2020 15:31:11 +0900 Subject: [PATCH 008/132] feat: add reservation create route --- .../Controllers/ReservationController.php | 38 +++++++++++++++++++ routes/web.php | 2 + 2 files changed, 40 insertions(+) create mode 100644 app/Http/Controllers/ReservationController.php diff --git a/app/Http/Controllers/ReservationController.php b/app/Http/Controllers/ReservationController.php new file mode 100644 index 00000000..d2e93f5f --- /dev/null +++ b/app/Http/Controllers/ReservationController.php @@ -0,0 +1,38 @@ +validate($request, [ + 'email' => ['required', 'string', 'email:rfc,dns'], + 'term_id' => ['required', 'string'], + 'people_count' => ['required', 'integer', 'gte:1'], + 'name' => ['required', 'string'], + 'address' => ['required', 'string'], + 'cellphone' => ['required', 'string', 'regex:/0\d{9,10}$/'] + ]); + + $reservation_id = 'R_'.Str::random(10); + while(true){ + if(!Revision::where('article_id', $reservation_id)->exists()) break; + $reservation_id = 'R_'.Str::random(10); + } + + $reservation = Reservation::create( + array_merge($request->all(), ['id' => $reservation_id]) + ); + + return response($reservation,201); + } + +} diff --git a/routes/web.php b/routes/web.php index 569d37ce..353b18b8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -45,4 +45,6 @@ $router->get('/ogimage/articles/{id}', ['uses' => 'OGImageController@getArticleImage']); $router->get('/ogimage/preview', ['uses' => 'OGImageController@getPreview']); +$router->post('/reservation', ['uses' => 'ReservationController@create']); + $router->options('{path:.*}', function(){}); // any path From 06b9c1c293acba020b903ad380cd706424840706 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 30 Aug 2020 20:53:27 +0900 Subject: [PATCH 009/132] fix: to response if query has unnessesary content --- app/Http/Controllers/ReservationController.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/ReservationController.php b/app/Http/Controllers/ReservationController.php index d2e93f5f..4d0157c7 100644 --- a/app/Http/Controllers/ReservationController.php +++ b/app/Http/Controllers/ReservationController.php @@ -2,18 +2,14 @@ namespace App\Http\Controllers; -use App\Http\Resources\RevisionResource; use App\Models\Reservation; -use App\Models\Revision; -use App\Models\WriterUser; use Illuminate\Http\Request; -use App\SlackNotify; use \Illuminate\Support\Str; class ReservationController extends Controller { public function create(Request $request) { - $this->validate($request, [ + $body = $this->validate($request, [ 'email' => ['required', 'string', 'email:rfc,dns'], 'term_id' => ['required', 'string'], 'people_count' => ['required', 'integer', 'gte:1'], @@ -24,12 +20,12 @@ public function create(Request $request) { $reservation_id = 'R_'.Str::random(10); while(true){ - if(!Revision::where('article_id', $reservation_id)->exists()) break; + if(!Reservation::where('id', $reservation_id)->exists()) break; $reservation_id = 'R_'.Str::random(10); } $reservation = Reservation::create( - array_merge($request->all(), ['id' => $reservation_id]) + array_merge($body, ['id' => $reservation_id]) ); return response($reservation,201); From e90fd7a21609f2fc4533bb5c108aa78044dbf1bc Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 30 Aug 2020 20:55:53 +0900 Subject: [PATCH 010/132] feat: add reservation with private resource --- .../ReservationWithPrivateResource.php | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 app/Http/Resources/ReservationWithPrivateResource.php diff --git a/app/Http/Resources/ReservationWithPrivateResource.php b/app/Http/Resources/ReservationWithPrivateResource.php new file mode 100644 index 00000000..1a7901a8 --- /dev/null +++ b/app/Http/Resources/ReservationWithPrivateResource.php @@ -0,0 +1,27 @@ + $this->id, + 'email' => $this->email, + 'term_id' => $this->term_id, + 'people_count' => $this->people_count, + 'name' => $this->name, + 'address' => $this->address, + 'cellphone' => $this->cellphone + ]; + } +} From 89c24bdf90b9656eae5b005e1793d31a7951b8ad Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 30 Aug 2020 20:58:22 +0900 Subject: [PATCH 011/132] feat: add reservation resource --- app/Http/Resources/ReservationResource.php | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 app/Http/Resources/ReservationResource.php diff --git a/app/Http/Resources/ReservationResource.php b/app/Http/Resources/ReservationResource.php new file mode 100644 index 00000000..49072578 --- /dev/null +++ b/app/Http/Resources/ReservationResource.php @@ -0,0 +1,24 @@ + $this->id, + 'email' => $this->email, + 'term_id' => $this->term_id, + 'people_count' => $this->people_count + ]; + } +} From 054865295ccbe16ac45fec3c6b50fd2521aed2f2 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 30 Aug 2020 20:58:38 +0900 Subject: [PATCH 012/132] feat: add reservation search method --- .../Controllers/ReservationController.php | 22 +++++++++++++++++++ routes/web.php | 1 + 2 files changed, 23 insertions(+) diff --git a/app/Http/Controllers/ReservationController.php b/app/Http/Controllers/ReservationController.php index 4d0157c7..705176a0 100644 --- a/app/Http/Controllers/ReservationController.php +++ b/app/Http/Controllers/ReservationController.php @@ -2,12 +2,34 @@ namespace App\Http\Controllers; +use App\Http\Resources\ReservationResource; use App\Models\Reservation; use Illuminate\Http\Request; use \Illuminate\Support\Str; class ReservationController extends Controller { + + public function index(Request $request) { + $query = $this->validate($request, [ + 'email' => ['string', 'email:rfc,dns'], + 'term_id' => ['string'], + 'people_count' => ['integer', 'gte:1'], + 'name' => ['string'], + 'address' => ['string'], + 'cellphone' => ['string', 'regex:/0\d{9,10}$/'] + ]); + + $response = Reservation::query(); + + foreach ($query as $i => $value){ + if ($i === 'q')continue; + if ($i === 'author_id')continue; + $response->where($i, $value); + } + + return response(ReservationResource::collection($response->get())); + } public function create(Request $request) { $body = $this->validate($request, [ 'email' => ['required', 'string', 'email:rfc,dns'], diff --git a/routes/web.php b/routes/web.php index 353b18b8..2d499418 100644 --- a/routes/web.php +++ b/routes/web.php @@ -46,5 +46,6 @@ $router->get('/ogimage/preview', ['uses' => 'OGImageController@getPreview']); $router->post('/reservation', ['uses' => 'ReservationController@create']); +$router->get('/reservation/search', ['uses' => 'ReservationController@index']); $router->options('{path:.*}', function(){}); // any path From 17b90a77a918672a739fdd72d62c33c7ad9c8942 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 30 Aug 2020 21:14:40 +0900 Subject: [PATCH 013/132] feat: add reservation show method --- app/Http/Controllers/ReservationController.php | 8 ++++++++ routes/web.php | 1 + 2 files changed, 9 insertions(+) diff --git a/app/Http/Controllers/ReservationController.php b/app/Http/Controllers/ReservationController.php index 705176a0..d4256f79 100644 --- a/app/Http/Controllers/ReservationController.php +++ b/app/Http/Controllers/ReservationController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Http\Resources\ReservationResource; +use App\Http\Resources\ReservationWithPrivateResource; use App\Models\Reservation; use Illuminate\Http\Request; use \Illuminate\Support\Str; @@ -53,4 +54,11 @@ public function create(Request $request) { return response($reservation,201); } + public function show($id) { + $reservation = Reservation::find($id); + if(!$reservation) abort(404); + + return response()->json(new ReservationWithPrivateResource($reservation)); + } + } diff --git a/routes/web.php b/routes/web.php index 2d499418..0ac36dc9 100644 --- a/routes/web.php +++ b/routes/web.php @@ -47,5 +47,6 @@ $router->post('/reservation', ['uses' => 'ReservationController@create']); $router->get('/reservation/search', ['uses' => 'ReservationController@index']); +$router->get('/reservation/{id}', ['uses' => 'ReservationController@show']); $router->options('{path:.*}', function(){}); // any path From 1b2648c292fed1123aa81a7ecad97153033b72a9 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Fri, 4 Sep 2020 17:29:20 +0900 Subject: [PATCH 014/132] feat: create HttpExceptionWithError --- app/Exceptions/Handler.php | 3 +++ app/Exceptions/HttpExceptionWithErrorCode.php | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 app/Exceptions/HttpExceptionWithErrorCode.php diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 8e1fb807..06192d9d 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -46,6 +46,9 @@ public function report(Exception $exception) public function render($request, Exception $exception) { $request->headers->set('Accept', 'application/json'); + if($exception instanceof HttpExceptionWithErrorCode){ + return response(['code'=>$exception->getStatusCode(), 'message'=>$exception->getMessage(), 'error_code'=>$exception->getErrorCode()], $exception->getStatusCode()); + } if($exception instanceof HttpException){ return response(['code'=>$exception->getStatusCode(), 'message'=>$exception->getMessage()], $exception->getStatusCode()); } diff --git a/app/Exceptions/HttpExceptionWithErrorCode.php b/app/Exceptions/HttpExceptionWithErrorCode.php new file mode 100644 index 00000000..c05b0a1c --- /dev/null +++ b/app/Exceptions/HttpExceptionWithErrorCode.php @@ -0,0 +1,21 @@ +errorCode = $errorCode; + + parent::__construct($httpCode); + } + + public function getErrorCode() + { + return $this->errorCode; + } +} From 8d04b6dc6bd8921c61e5072b5b40ff8044e28386 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 5 Sep 2020 16:21:32 +0900 Subject: [PATCH 015/132] feat: add general/enter path about guest --- app/Http/Controllers/GuestController.php | 62 ++++++++++++++++++++++++ routes/web.php | 2 + 2 files changed, 64 insertions(+) create mode 100644 app/Http/Controllers/GuestController.php diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php new file mode 100644 index 00000000..81da964a --- /dev/null +++ b/app/Http/Controllers/GuestController.php @@ -0,0 +1,62 @@ +validate($request, [ + 'reservation_id' => ['string', 'required'], + 'guest_id' => ['string', 'required'] + ]); + + $reserv = Reservation::find($request->reservation_id); + + if(!$reserv) throw new HttpExceptionWithErrorCode(404, 'RESERVATION_NOT_FOUND'); + + if(Guest::where('reservation_id', $reserv)->exists()) { + throw new HttpExceptionWithErrorCode(409, 'ALREADY_ENTERED_RESERVATION'); + } + + // TODO: wristBand 形式チェック + + // TODO: wristBand の重複チェック + if(Guest::find($request->guest_id)) { + throw new HttpExceptionWithErrorCode(409, 'ALREADY_USED_WRISTBAND'); + } + + $term = $reserv->term; + $current = Carbon::now()->timestamp; + + if( + $term->enter_scheduled_time > $current + || $term->exit_scheduled_time < $current + ) { + throw new HttpExceptionWithErrorCode(400, 'OUT_OF_RESERVATION_TIME'); + } + + $exit_time = $term->exit_scheduled_time; + $color_id = $term->color_id; + + // TODO: wristBand の term が一致するかのチェック + + $guest = Guest::create( + [ + 'id' => $request->guest_id, + 'term_id' => $term->id, + 'reservation_id' => $request->reservation_id + ] + ); + + return response()->json($guest); + } +} diff --git a/routes/web.php b/routes/web.php index 0ac36dc9..e6b143e6 100644 --- a/routes/web.php +++ b/routes/web.php @@ -49,4 +49,6 @@ $router->get('/reservation/search', ['uses' => 'ReservationController@index']); $router->get('/reservation/{id}', ['uses' => 'ReservationController@show']); +$router->post('/general/enter', ['uses' => 'GuestController@enter']); + $router->options('{path:.*}', function(){}); // any path From 86ebd71dd9215e67201d1271b53fcd94040e50e0 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 6 Sep 2020 14:00:28 +0900 Subject: [PATCH 016/132] feat: add general exit method --- app/Http/Controllers/GuestController.php | 19 +++++++++++++++++++ routes/web.php | 1 + 2 files changed, 20 insertions(+) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index 81da964a..0b9a7d82 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -59,4 +59,23 @@ public function enter(Request $request){ return response()->json($guest); } + + public function exit(Request $request){ + $this->validate($request, [ + 'guest_id' => ['string', 'required'] + ]); + + $guest = Guest::find($request->guest_id); + if(!$guest) { + abort(404); + } + + if($guest->exited_at != NULL) { + abort(409); + } + + $guest->update(['exited_at' => Carbon::now()]); + + return response()->json(); + } } diff --git a/routes/web.php b/routes/web.php index e6b143e6..170e46e3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -50,5 +50,6 @@ $router->get('/reservation/{id}', ['uses' => 'ReservationController@show']); $router->post('/general/enter', ['uses' => 'GuestController@enter']); +$router->post('/general/exit', ['uses' => 'GuestController@exit']); $router->options('{path:.*}', function(){}); // any path From dac29c822ffabb26c44ac60abe94770cacd55efd Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 6 Sep 2020 16:53:31 +0900 Subject: [PATCH 017/132] feat: craete manage config and write color --- config/manage.php | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 config/manage.php diff --git a/config/manage.php b/config/manage.php new file mode 100644 index 00000000..21610518 --- /dev/null +++ b/config/manage.php @@ -0,0 +1,48 @@ + [ + 'blue' => [ + 'prefix' => 'GB' + ], + 'red' => [ + 'prefix' => 'GR' + ], + 'yellow' => [ + 'prefix' => 'GY' + ], + 'violet' => [ + 'prefix' => 'GV' + ], + 'orange' => [ + 'prefix' => 'GO' + ], + 'green' => [ + 'prefix' => 'GG' + ], + 'white' => [ + 'prefix' => 'GW' + ], + 'gray' => [ + 'prefix' => 'GS' + ], + 'test_blue' => [ + 'prefix' => 'TB' + ], + 'test_red' => [ + 'prefix' => 'TR' + ], + 'test_yellow' => [ + 'prefix' => 'TY' + ] + ] +]; From 27dd42071899f1953b59bfbdeaede163074e5b06 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 6 Sep 2020 20:10:21 +0900 Subject: [PATCH 018/132] fix: add manage config --- bootstrap/app.php | 1 + 1 file changed, 1 insertion(+) mode change 100644 => 100755 bootstrap/app.php diff --git a/bootstrap/app.php b/bootstrap/app.php old mode 100644 new mode 100755 index 811887ec..3424526f --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -103,5 +103,6 @@ }); $app->configure('blog'); +$app->configure('manage'); return $app; From 772fb4a9410c95e8feb29c84a243c608dc9e86c1 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 6 Sep 2020 20:29:04 +0900 Subject: [PATCH 019/132] feat: check wrong_wristband_color --- app/Http/Controllers/GuestController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index 0b9a7d82..8d07a152 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -36,6 +36,14 @@ public function enter(Request $request){ $term = $reserv->term; $current = Carbon::now()->timestamp; + if( + !preg_match( + '/^'.config('manage.colors')[$term->color_id]['prefix'].'/', + $request->guest_id + ) + ) { + throw new HttpExceptionWithErrorCode(400, 'WRONG_WRISTBAND_COLOR'); + } if( $term->enter_scheduled_time > $current From 679cdf84210746ee5e388ad6b0575b689e3c47dc Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 6 Sep 2020 20:31:04 +0900 Subject: [PATCH 020/132] docs: change reservation prefix --- app/Http/Controllers/ReservationController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ReservationController.php b/app/Http/Controllers/ReservationController.php index d4256f79..b85dd7b4 100644 --- a/app/Http/Controllers/ReservationController.php +++ b/app/Http/Controllers/ReservationController.php @@ -41,10 +41,10 @@ public function create(Request $request) { 'cellphone' => ['required', 'string', 'regex:/0\d{9,10}$/'] ]); - $reservation_id = 'R_'.Str::random(10); + $reservation_id = 'R-'.Str::random(10); while(true){ if(!Reservation::where('id', $reservation_id)->exists()) break; - $reservation_id = 'R_'.Str::random(10); + $reservation_id = 'R-'.Str::random(10); } $reservation = Reservation::create( From 291aadc93fe80b440ceda45f60cd372abb46e514 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 6 Sep 2020 20:31:24 +0900 Subject: [PATCH 021/132] fix: to use in MySQL --- app/Http/Controllers/GuestController.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index 8d07a152..a650d431 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -35,7 +35,7 @@ public function enter(Request $request){ } $term = $reserv->term; - $current = Carbon::now()->timestamp; + $current = Carbon::now(); if( !preg_match( '/^'.config('manage.colors')[$term->color_id]['prefix'].'/', @@ -46,8 +46,8 @@ public function enter(Request $request){ } if( - $term->enter_scheduled_time > $current - || $term->exit_scheduled_time < $current + new Carbon($term->enter_scheduled_time) > $current + || new Carbon($term->exit_scheduled_time) < $current ) { throw new HttpExceptionWithErrorCode(400, 'OUT_OF_RESERVATION_TIME'); } @@ -65,6 +65,8 @@ public function enter(Request $request){ ] ); + // TODO: reservation に guest_id を設定する + return response()->json($guest); } From af0942d7c972faf0614e022e737a5c0f5307e79d Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 6 Sep 2020 20:43:06 +0900 Subject: [PATCH 022/132] feat: now check wrish_band code --- app/Http/Controllers/GuestController.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index a650d431..fb459335 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -19,6 +19,10 @@ public function enter(Request $request){ 'guest_id' => ['string', 'required'] ]); + if(!preg_match('/^[A-Z]{2,3}-[a-zA-Z0-9]{10}$/', $request->guest_id)){ + throw new HttpExceptionWithErrorCode(409, 'INVALID_WRISTBAND_CODE'); + } + $reserv = Reservation::find($request->reservation_id); if(!$reserv) throw new HttpExceptionWithErrorCode(404, 'RESERVATION_NOT_FOUND'); @@ -27,9 +31,6 @@ public function enter(Request $request){ throw new HttpExceptionWithErrorCode(409, 'ALREADY_ENTERED_RESERVATION'); } - // TODO: wristBand 形式チェック - - // TODO: wristBand の重複チェック if(Guest::find($request->guest_id)) { throw new HttpExceptionWithErrorCode(409, 'ALREADY_USED_WRISTBAND'); } From d381cb48f2bd79d22d40207b57d328152d6d4160 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Wed, 9 Sep 2020 21:54:48 +0900 Subject: [PATCH 023/132] feat: add guest resource --- app/Http/Controllers/GuestController.php | 3 +- app/Http/Resources/GuestResource.php | 35 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 app/Http/Resources/GuestResource.php diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index fb459335..070b8e51 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Exceptions\HttpExceptionWithErrorCode; +use App\Http\Resources\GuestResource; use App\Models\Guest; use App\Models\Image; use App\Models\Reservation; @@ -68,7 +69,7 @@ public function enter(Request $request){ // TODO: reservation に guest_id を設定する - return response()->json($guest); + return response()->json(new GuestResource($guest)); } public function exit(Request $request){ diff --git a/app/Http/Resources/GuestResource.php b/app/Http/Resources/GuestResource.php new file mode 100644 index 00000000..144a6b6c --- /dev/null +++ b/app/Http/Resources/GuestResource.php @@ -0,0 +1,35 @@ + $this->id, + 'color_id' => $this->term->color_id, + 'term_id' => $this->term->id, + 'entered_at' => $this->entered_at, + 'exit_scheduled_time' => $this->term->exit_scheduled_time, + 'exited_at' => $this->exited_at, + 'exh_id' =>$this->exh_id, + ]; + } + + private function removeWrap($title) { + $res = $title; + $res = rawurldecode($res); + $res = str_replace("%0A", '', $res); + $res = str_replace("\\n", '', $res); + return $res; + } +} From d796f5819971b9766cb803ca732acf6fe2034830 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Wed, 9 Sep 2020 22:04:03 +0900 Subject: [PATCH 024/132] feat: add guest show path --- app/Http/Controllers/GuestController.php | 9 +++++++++ routes/web.php | 1 + 2 files changed, 10 insertions(+) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index 070b8e51..b1a15a85 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -14,6 +14,15 @@ class GuestController extends Controller { + public function show(Request $request, $id){ + $guest = Guest::find($id); + if(!$guest){ + abort(404); + } + + return response()->json(new GuestResource($guest)); + } + public function enter(Request $request){ $this->validate($request, [ 'reservation_id' => ['string', 'required'], diff --git a/routes/web.php b/routes/web.php index acf9b545..150a98c8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -45,6 +45,7 @@ $router->get('/reservation/search', ['uses' => 'ReservationController@index']); $router->get('/reservation/{id}', ['uses' => 'ReservationController@show']); +$router->get('/general/guest/{id}', ['uses' => 'GuestController@show']); $router->post('/general/enter', ['uses' => 'GuestController@enter']); $router->post('/general/exit', ['uses' => 'GuestController@exit']); From 2c39b074b64aec9fd5371ae904ea3ba3c4823384 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Wed, 9 Sep 2020 22:15:46 +0900 Subject: [PATCH 025/132] feat: add guest index route --- app/Http/Controllers/GuestController.php | 4 ++++ routes/web.php | 1 + 2 files changed, 5 insertions(+) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index b1a15a85..6b4f5a4f 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -23,6 +23,10 @@ public function show(Request $request, $id){ return response()->json(new GuestResource($guest)); } + public function index(){ + return response()->json(GuestResource::collection((Guest::all()))); + } + public function enter(Request $request){ $this->validate($request, [ 'reservation_id' => ['string', 'required'], diff --git a/routes/web.php b/routes/web.php index 150a98c8..4e2327dd 100644 --- a/routes/web.php +++ b/routes/web.php @@ -45,6 +45,7 @@ $router->get('/reservation/search', ['uses' => 'ReservationController@index']); $router->get('/reservation/{id}', ['uses' => 'ReservationController@show']); +$router->get('/general/guest/', ['uses' => 'GuestController@index']); $router->get('/general/guest/{id}', ['uses' => 'GuestController@show']); $router->post('/general/enter', ['uses' => 'GuestController@enter']); $router->post('/general/exit', ['uses' => 'GuestController@exit']); From 358ad48bad14a3dc45bbd6fa55d26bdf5de64285 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 14 Feb 2021 19:34:07 +0900 Subject: [PATCH 026/132] fix: change guestId format to (XX-XXXXX) --- app/Http/Controllers/GuestController.php | 2 +- config/manage.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index 6b4f5a4f..5de49e21 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -33,7 +33,7 @@ public function enter(Request $request){ 'guest_id' => ['string', 'required'] ]); - if(!preg_match('/^[A-Z]{2,3}-[a-zA-Z0-9]{10}$/', $request->guest_id)){ + if(!preg_match('/^[A-Z]{2,3}-[a-zA-Z0-9]{5}$/', $request->guest_id)){ throw new HttpExceptionWithErrorCode(409, 'INVALID_WRISTBAND_CODE'); } diff --git a/config/manage.php b/config/manage.php index 21610518..8c793c46 100644 --- a/config/manage.php +++ b/config/manage.php @@ -33,7 +33,7 @@ 'prefix' => 'GW' ], 'gray' => [ - 'prefix' => 'GS' + 'prefix' => 'SG' ], 'test_blue' => [ 'prefix' => 'TB' From 5885af12a4ebc3dfc9419dc515a69ba4b4964b2f Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Mon, 15 Feb 2021 16:21:48 +0900 Subject: [PATCH 027/132] feat: update afes/docs --- routes/web.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/routes/web.php b/routes/web.php index 4e2327dd..b509ba9f 100644 --- a/routes/web.php +++ b/routes/web.php @@ -41,13 +41,13 @@ $router->get('/ogimage/articles/{id}', ['uses' => 'OGImageController@getArticleImage']); $router->get('/ogimage/preview', ['uses' => 'OGImageController@getPreview']); -$router->post('/reservation', ['uses' => 'ReservationController@create']); -$router->get('/reservation/search', ['uses' => 'ReservationController@index']); -$router->get('/reservation/{id}', ['uses' => 'ReservationController@show']); - -$router->get('/general/guest/', ['uses' => 'GuestController@index']); -$router->get('/general/guest/{id}', ['uses' => 'GuestController@show']); -$router->post('/general/enter', ['uses' => 'GuestController@enter']); -$router->post('/general/exit', ['uses' => 'GuestController@exit']); +$router->post('/onsite/reservation', ['uses' => 'ReservationController@create']); +$router->get('/onsite/reservation/search', ['uses' => 'ReservationController@index']); +$router->get('/onsite/reservation/{id}', ['uses' => 'ReservationController@show']); + +$router->get('/onsite/general/guest/', ['uses' => 'GuestController@index']); +$router->get('/onsite/general/guest/{id}', ['uses' => 'GuestController@show']); +$router->post('/onsite/general/enter', ['uses' => 'GuestController@enter']); +$router->post('/onsite/general/exit', ['uses' => 'GuestController@exit']); $router->options('{path:.*}', function(){}); // any path From e3bb6dadef7c11ecea96630a3e0979654bd437d5 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Mon, 15 Feb 2021 16:22:29 +0900 Subject: [PATCH 028/132] feat: Wristband prefix check --- app/Http/Controllers/GuestController.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index 5de49e21..b44d9c04 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -11,6 +11,7 @@ use Illuminate\Support\Str; use App\SlackNotify; use Carbon\Carbon; +use App\Models\ActivityLog; class GuestController extends Controller { @@ -67,11 +68,15 @@ public function enter(Request $request){ throw new HttpExceptionWithErrorCode(400, 'OUT_OF_RESERVATION_TIME'); } - $exit_time = $term->exit_scheduled_time; - $color_id = $term->color_id; + $wb_prefix = $term->color_id.'-'; // TODO: wristBand の term が一致するかのチェック + if(strpos($request->guest_id, $wb_prefix) !== 0){ + throw new HttpExceptionWithErrorCode(400, 'WRONG_WRISTBAND_COLOR'); + } + + $guest = Guest::create( [ 'id' => $request->guest_id, @@ -80,7 +85,7 @@ public function enter(Request $request){ ] ); - // TODO: reservation に guest_id を設定する + $reserv->update(['guest_id' => $guest->id]); return response()->json(new GuestResource($guest)); } @@ -101,6 +106,11 @@ public function exit(Request $request){ $guest->update(['exited_at' => Carbon::now()]); - return response()->json(); + return response()->json($guest); + } + + public function show_log(Request $request, $id){ + $logs = ActivityLog::query()->where('id', $id)->get(); + return response()->json($logs); } } From 7b2013b828a5a7fd2fc25e1941a892a6fa0766c9 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 16 Feb 2021 10:38:07 +0900 Subject: [PATCH 029/132] feat: ALREADY_ENTERED_RESERVATION error --- app/Http/Controllers/GuestController.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index b44d9c04..b4d20d57 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -70,12 +70,15 @@ public function enter(Request $request){ $wb_prefix = $term->color_id.'-'; - // TODO: wristBand の term が一致するかのチェック - if(strpos($request->guest_id, $wb_prefix) !== 0){ throw new HttpExceptionWithErrorCode(400, 'WRONG_WRISTBAND_COLOR'); } + if($reserv->guest_id !== NULL){ + throw new HttpExceptionWithErrorCode(400, 'ALREADY_ENTERED_RESERVATION'); + + } + $guest = Guest::create( [ @@ -85,6 +88,7 @@ public function enter(Request $request){ ] ); + // TODO: 複数人で処理するときの扱いを考える (docsの編集待ち) $reserv->update(['guest_id' => $guest->id]); return response()->json(new GuestResource($guest)); From c5c41e1c63f695b3510ef6e1aeb7312152bd7f78 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 16 Feb 2021 10:39:13 +0900 Subject: [PATCH 030/132] fix: problem of throw with not 400 code in guest/enter --- app/Http/Controllers/GuestController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index b4d20d57..8e87545b 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -35,19 +35,19 @@ public function enter(Request $request){ ]); if(!preg_match('/^[A-Z]{2,3}-[a-zA-Z0-9]{5}$/', $request->guest_id)){ - throw new HttpExceptionWithErrorCode(409, 'INVALID_WRISTBAND_CODE'); + throw new HttpExceptionWithErrorCode(400, 'INVALID_WRISTBAND_CODE'); } $reserv = Reservation::find($request->reservation_id); - if(!$reserv) throw new HttpExceptionWithErrorCode(404, 'RESERVATION_NOT_FOUND'); + if(!$reserv) throw new HttpExceptionWithErrorCode(400, 'RESERVATION_NOT_FOUND'); if(Guest::where('reservation_id', $reserv)->exists()) { - throw new HttpExceptionWithErrorCode(409, 'ALREADY_ENTERED_RESERVATION'); + throw new HttpExceptionWithErrorCode(400, 'ALREADY_ENTERED_RESERVATION'); } if(Guest::find($request->guest_id)) { - throw new HttpExceptionWithErrorCode(409, 'ALREADY_USED_WRISTBAND'); + throw new HttpExceptionWithErrorCode(400, 'ALREADY_USED_WRISTBAND'); } $term = $reserv->term; From f978b2bb2e38a4ac63b8c69f0554deef6d2cee46 Mon Sep 17 00:00:00 2001 From: subaru Date: Tue, 16 Feb 2021 11:17:35 +0900 Subject: [PATCH 031/132] fix: don't always return WRONG_WRISTBAND_COLOR --- app/Http/Controllers/GuestController.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index 8e87545b..880fa152 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -68,18 +68,10 @@ public function enter(Request $request){ throw new HttpExceptionWithErrorCode(400, 'OUT_OF_RESERVATION_TIME'); } - $wb_prefix = $term->color_id.'-'; - - if(strpos($request->guest_id, $wb_prefix) !== 0){ - throw new HttpExceptionWithErrorCode(400, 'WRONG_WRISTBAND_COLOR'); - } - if($reserv->guest_id !== NULL){ throw new HttpExceptionWithErrorCode(400, 'ALREADY_ENTERED_RESERVATION'); - } - $guest = Guest::create( [ 'id' => $request->guest_id, From 0eac1a273eb9def310333ddb1eb201d467b958b9 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Wed, 17 Feb 2021 11:54:50 +0900 Subject: [PATCH 032/132] feat: reservetion->hasProblem method --- app/Http/Controllers/GuestController.php | 18 +++++------------- app/Models/Reservation.php | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index 880fa152..bc434ed2 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -42,8 +42,10 @@ public function enter(Request $request){ if(!$reserv) throw new HttpExceptionWithErrorCode(400, 'RESERVATION_NOT_FOUND'); - if(Guest::where('reservation_id', $reserv)->exists()) { - throw new HttpExceptionWithErrorCode(400, 'ALREADY_ENTERED_RESERVATION'); + $reserv_res = $reserv->hasProblem(); + + if($reserv_res !== false){ + throw new HttpExceptionWithErrorCode(400, $reserv_res); } if(Guest::find($request->guest_id)) { @@ -51,7 +53,7 @@ public function enter(Request $request){ } $term = $reserv->term; - $current = Carbon::now(); + if( !preg_match( '/^'.config('manage.colors')[$term->color_id]['prefix'].'/', @@ -61,16 +63,6 @@ public function enter(Request $request){ throw new HttpExceptionWithErrorCode(400, 'WRONG_WRISTBAND_COLOR'); } - if( - new Carbon($term->enter_scheduled_time) > $current - || new Carbon($term->exit_scheduled_time) < $current - ) { - throw new HttpExceptionWithErrorCode(400, 'OUT_OF_RESERVATION_TIME'); - } - - if($reserv->guest_id !== NULL){ - throw new HttpExceptionWithErrorCode(400, 'ALREADY_ENTERED_RESERVATION'); - } $guest = Guest::create( [ diff --git a/app/Models/Reservation.php b/app/Models/Reservation.php index bea8ddea..2dea91fd 100644 --- a/app/Models/Reservation.php +++ b/app/Models/Reservation.php @@ -2,6 +2,7 @@ namespace App\Models; +use Carbon\Carbon; use Illuminate\Auth\Authenticatable; use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; @@ -43,4 +44,22 @@ public function guest() { public function term() { return $this->belongsTo('\App\Models\Term'); } + + public function hasProblem() { + $term = $this->term; + $current = Carbon::now(); + + if( + new Carbon($term->enter_scheduled_time) > $current + || new Carbon($term->exit_scheduled_time) < $current + ) { + return 'OUT_OF_RESERVATION_TIME'; + } + + if($this->guest_id !== NULL){ + return 'ALREADY_ENTERED_RESERVATION'; + } + + return false; + } } From 76c98ba8308b6767e2e4ae8df6532719ecb3c427 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Wed, 17 Feb 2021 15:48:54 +0900 Subject: [PATCH 033/132] feat: reservation check --- .../Controllers/ReservationController.php | 20 +++++++++++++++++++ routes/web.php | 3 +++ 2 files changed, 23 insertions(+) diff --git a/app/Http/Controllers/ReservationController.php b/app/Http/Controllers/ReservationController.php index b85dd7b4..562a2573 100644 --- a/app/Http/Controllers/ReservationController.php +++ b/app/Http/Controllers/ReservationController.php @@ -61,4 +61,24 @@ public function show($id) { return response()->json(new ReservationWithPrivateResource($reservation)); } + public function check($id) { + $reservation = Reservation::find($id); + if(!$reservation) abort(404); + + $status_code = $reservation->hasProblem(); + if($status_code !== false) { + $valid = false; + }else{ + $valid = true; + $status_code = null; + } + + $res = [ + 'valid' => $valid, + 'status_code' => $status_code, + 'term_id' => $reservation->term_id + ]; + + return response()->json($res); + } } diff --git a/routes/web.php b/routes/web.php index b509ba9f..76bfab53 100644 --- a/routes/web.php +++ b/routes/web.php @@ -44,6 +44,9 @@ $router->post('/onsite/reservation', ['uses' => 'ReservationController@create']); $router->get('/onsite/reservation/search', ['uses' => 'ReservationController@index']); $router->get('/onsite/reservation/{id}', ['uses' => 'ReservationController@show']); +$router->get('/onsite/reservation/{id}/check', ['uses' => 'ReservationController@check']); + +// TODO: 権限設定 $router->get('/onsite/general/guest/', ['uses' => 'GuestController@index']); $router->get('/onsite/general/guest/{id}', ['uses' => 'GuestController@show']); From 9c6b3124aee5a10832ab2bf1de14a63942aea44a Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Thu, 18 Feb 2021 10:11:45 +0900 Subject: [PATCH 034/132] feat: exhibition room model/migration --- app/Models/ExhibitionRoom.php | 41 +++++++++++++++++++ ...8_005707_create_exhibition_rooms_table.php | 35 ++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 app/Models/ExhibitionRoom.php create mode 100644 database/migrations/2021_02_18_005707_create_exhibition_rooms_table.php diff --git a/app/Models/ExhibitionRoom.php b/app/Models/ExhibitionRoom.php new file mode 100644 index 00000000..74b60653 --- /dev/null +++ b/app/Models/ExhibitionRoom.php @@ -0,0 +1,41 @@ +string('id'); + $table->primary('id'); + $table->string('room_id'); + $table->unsignedInteger('capacity'); + $table->unsignedInteger('guest_count'); + $table->timestamp('updated_at')->useCurrent(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('exh_rooms'); + } +} From f08e6a80ddafe704fbcbbc6d8dd2dcc5f8754819 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Fri, 19 Feb 2021 22:08:02 +0900 Subject: [PATCH 035/132] fix: set table name in exh_room model --- app/Models/ExhibitionRoom.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Models/ExhibitionRoom.php b/app/Models/ExhibitionRoom.php index 74b60653..55e4f10a 100644 --- a/app/Models/ExhibitionRoom.php +++ b/app/Models/ExhibitionRoom.php @@ -29,6 +29,8 @@ class ExhibitionRoom extends Model implements AuthenticatableContract, Authoriza */ protected $hidden = []; + protected $table = 'exh_rooms'; + protected $primaryKey = 'id'; protected $keyType = 'string'; From 0b6aef0d675d05d2f3de69a3325591a0f331394a Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Fri, 19 Feb 2021 22:09:51 +0900 Subject: [PATCH 036/132] feat: exhroom model: guest_relation --- app/Models/ExhibitionRoom.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Models/ExhibitionRoom.php b/app/Models/ExhibitionRoom.php index 55e4f10a..fcc41f53 100644 --- a/app/Models/ExhibitionRoom.php +++ b/app/Models/ExhibitionRoom.php @@ -40,4 +40,8 @@ class ExhibitionRoom extends Model implements AuthenticatableContract, Authoriza const CREATED_AT = null; const UPDATED_AT = 'updated_at'; + + public function guests() { + return $this->hasMany('\App\Models\Guest', 'exh_id'); + } } From ff3e7927f8b9c29465e3f4eb7648ad7031d79e46 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 20 Feb 2021 22:25:35 +0900 Subject: [PATCH 037/132] feat: permission settings --- routes/web.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/routes/web.php b/routes/web.php index 76bfab53..312bd224 100644 --- a/routes/web.php +++ b/routes/web.php @@ -42,11 +42,9 @@ $router->get('/ogimage/preview', ['uses' => 'OGImageController@getPreview']); $router->post('/onsite/reservation', ['uses' => 'ReservationController@create']); -$router->get('/onsite/reservation/search', ['uses' => 'ReservationController@index']); -$router->get('/onsite/reservation/{id}', ['uses' => 'ReservationController@show']); -$router->get('/onsite/reservation/{id}/check', ['uses' => 'ReservationController@check']); - -// TODO: 権限設定 +$router->get('/onsite/reservation/search', ['uses' => 'ReservationController@index', 'middleware'=>'auth:reservation']); +$router->get('/onsite/reservation/{id}', ['uses' => 'ReservationController@show', 'middleware'=>'auth:reservation']); +$router->get('/onsite/reservation/{id}/check', ['uses' => 'ReservationController@check', 'middleware'=>'auth:reservation,general']); $router->get('/onsite/general/guest/', ['uses' => 'GuestController@index']); $router->get('/onsite/general/guest/{id}', ['uses' => 'GuestController@show']); From 90d659c22f9d98877d953128764f9a529ff4c7df Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Mon, 22 Feb 2021 22:49:14 +0900 Subject: [PATCH 038/132] feat: exhibition show --- .../Controllers/ExhibitionRoomController.php | 28 +++++++++++++++++++ app/Http/Resources/ExhibitionRoomResource.php | 24 ++++++++++++++++ app/Models/ExhibitionRoom.php | 12 ++++++++ routes/web.php | 2 ++ 4 files changed, 66 insertions(+) create mode 100644 app/Http/Controllers/ExhibitionRoomController.php create mode 100644 app/Http/Resources/ExhibitionRoomResource.php diff --git a/app/Http/Controllers/ExhibitionRoomController.php b/app/Http/Controllers/ExhibitionRoomController.php new file mode 100644 index 00000000..a9059535 --- /dev/null +++ b/app/Http/Controllers/ExhibitionRoomController.php @@ -0,0 +1,28 @@ +json(new ExhibitionRoomResource($exhibition)); + } +} diff --git a/app/Http/Resources/ExhibitionRoomResource.php b/app/Http/Resources/ExhibitionRoomResource.php new file mode 100644 index 00000000..230d7bc5 --- /dev/null +++ b/app/Http/Resources/ExhibitionRoomResource.php @@ -0,0 +1,24 @@ + $this->countGuest(), + 'limit' => $this->capacity, + 'room_id' => $this->room_id, + ]; + } +} diff --git a/app/Models/ExhibitionRoom.php b/app/Models/ExhibitionRoom.php index fcc41f53..c8c5c136 100644 --- a/app/Models/ExhibitionRoom.php +++ b/app/Models/ExhibitionRoom.php @@ -44,4 +44,16 @@ class ExhibitionRoom extends Model implements AuthenticatableContract, Authoriza public function guests() { return $this->hasMany('\App\Models\Guest', 'exh_id'); } + + public function countGuest() { + $terms = Term::all(); + $res = []; + foreach($terms as $term){ + $guest = $this->guests->where('term_id',$term->id); + $count = count($guest); + if($count==0) continue; + $res[$term->id] = $count; + } + return $res; + } } diff --git a/routes/web.php b/routes/web.php index 312bd224..69bc9c5b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -51,4 +51,6 @@ $router->post('/onsite/general/enter', ['uses' => 'GuestController@enter']); $router->post('/onsite/general/exit', ['uses' => 'GuestController@exit']); +$router->get('/onsite/exhibition/status/{id}', ['uses' => 'ExhibitionRoomController@show']); + $router->options('{path:.*}', function(){}); // any path From 6728172600945418212ab8216c25eb6718ebcff8 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Mon, 22 Feb 2021 23:12:51 +0900 Subject: [PATCH 039/132] feat: exhibition enter --- .../Controllers/ExhibitionRoomController.php | 38 +++++++++++++++++++ routes/web.php | 1 + 2 files changed, 39 insertions(+) diff --git a/app/Http/Controllers/ExhibitionRoomController.php b/app/Http/Controllers/ExhibitionRoomController.php index a9059535..e0648736 100644 --- a/app/Http/Controllers/ExhibitionRoomController.php +++ b/app/Http/Controllers/ExhibitionRoomController.php @@ -25,4 +25,42 @@ public function show(Request $request, $id){ return response()->json(new ExhibitionRoomResource($exhibition)); } + + public function enter(Request $request){ + $this->validate($request, [ + 'guest_id' => ['string', 'required'] + ]); + + $user_id = $request->user()->id; + $guest = Guest::find($request->guest_id); + $exh = ExhibitionRoom::find($user_id); + $current = Carbon::now(); + + if(!$guest) throw new HttpExceptionWithErrorCode(400, 'GUEST_NOT_FOUND'); + + if($guest->exh_id === $user_id) + throw new HttpExceptionWithErrorCode(400, 'GUEST_ALREADY_ENTERED'); + + if($exh->capacity === $exh->guest_count) + throw new HttpExceptionWithErrorCode(400, 'PEOPLE_LIMIT_EXCEEDED'); + + if($guest->exited_at !== NULL) + throw new HttpExceptionWithErrorCode(400, 'GUEST_ALREADY_EXITED'); + + if( + new Carbon($guest->term->exit_scheduled_time) < $current + ) + throw new HttpExceptionWithErrorCode(400, 'EXIT_TIME_EXCEEDED'); + + + $guest->update(['exh_id' => $exh->id]); + + ActivityLog::create([ + 'exh_id' => $exh->id, + 'log_type' => 'enter', + 'guest_id' => $guest->id + ]); + + return response()->json(new GuestResource($guest)); + } } diff --git a/routes/web.php b/routes/web.php index 69bc9c5b..1ca43e55 100644 --- a/routes/web.php +++ b/routes/web.php @@ -52,5 +52,6 @@ $router->post('/onsite/general/exit', ['uses' => 'GuestController@exit']); $router->get('/onsite/exhibition/status/{id}', ['uses' => 'ExhibitionRoomController@show']); +$router->post('/onsite/exhibition/enter', ['uses' => 'ExhibitionRoomController@enter']); $router->options('{path:.*}', function(){}); // any path From 5bb84ff5f227a9ca906c32151bf273f346ad7bc7 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 23 Feb 2021 21:06:14 +0900 Subject: [PATCH 040/132] feat: exhibition exit --- .../Controllers/ExhibitionRoomController.php | 29 +++++++++++++++++++ routes/web.php | 1 + 2 files changed, 30 insertions(+) diff --git a/app/Http/Controllers/ExhibitionRoomController.php b/app/Http/Controllers/ExhibitionRoomController.php index e0648736..389244e0 100644 --- a/app/Http/Controllers/ExhibitionRoomController.php +++ b/app/Http/Controllers/ExhibitionRoomController.php @@ -63,4 +63,33 @@ public function enter(Request $request){ return response()->json(new GuestResource($guest)); } + + public function exit(Request $request){ + $this->validate($request, [ + 'guest_id' => ['string', 'required'] + ]); + + $this->validate($request, [ + 'guest_id' => ['string', 'required'] + ]); + + $user_id = $request->user()->id; + $guest = Guest::find($request->guest_id); + $exh = ExhibitionRoom::find($user_id); + + if(!$guest) throw new HttpExceptionWithErrorCode(400, 'GUEST_NOT_FOUND'); + + if($guest->exited_at !== NULL) + throw new HttpExceptionWithErrorCode(400, 'GUEST_ALREADY_EXITED'); + + $guest->update(['exh_id' => null]); + + ActivityLog::create([ + 'exh_id' => $exh->id, + 'log_type' => 'exit', + 'guest_id' => $guest->id + ]); + + return response()->json(new GuestResource($guest)); + } } diff --git a/routes/web.php b/routes/web.php index 1ca43e55..4c7c2adf 100644 --- a/routes/web.php +++ b/routes/web.php @@ -53,5 +53,6 @@ $router->get('/onsite/exhibition/status/{id}', ['uses' => 'ExhibitionRoomController@show']); $router->post('/onsite/exhibition/enter', ['uses' => 'ExhibitionRoomController@enter']); +$router->post('/onsite/exhibition/exit', ['uses' => 'ExhibitionRoomController@exit']); $router->options('{path:.*}', function(){}); // any path From f5a56855cbe6545b3c51267be26c33f1e75a2810 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 23 Feb 2021 21:25:26 +0900 Subject: [PATCH 041/132] feat: activity_log resource --- app/Http/Resources/ActivityLogResource.php | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 app/Http/Resources/ActivityLogResource.php diff --git a/app/Http/Resources/ActivityLogResource.php b/app/Http/Resources/ActivityLogResource.php new file mode 100644 index 00000000..946c0c39 --- /dev/null +++ b/app/Http/Resources/ActivityLogResource.php @@ -0,0 +1,25 @@ + $this->id, + 'timestamp' => $this->timestamp->toIso8601ZuluString(), + 'guest' => new GuestResource($this->guest), + 'exh_id' => $this->exh_id, + 'log_type' => $this->log_type + ]; + } +} From 59e13a37331063937ce03ae90fab76343915e491 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 23 Feb 2021 21:25:55 +0900 Subject: [PATCH 042/132] fix: pass through resource in guest/exit, showlog --- app/Http/Controllers/GuestController.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index bc434ed2..7ad666f8 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Exceptions\HttpExceptionWithErrorCode; +use App\Http\Resources\ActivityLogResource; use App\Http\Resources\GuestResource; use App\Models\Guest; use App\Models\Image; @@ -94,11 +95,11 @@ public function exit(Request $request){ $guest->update(['exited_at' => Carbon::now()]); - return response()->json($guest); + return response()->json(new GuestResource($guest)); } public function show_log(Request $request, $id){ - $logs = ActivityLog::query()->where('id', $id)->get(); - return response()->json($logs); + $logs = ActivityLog::query()->where('guest_id', $id)->get(); + return response()->json(ActivityLogResource::collection($logs)); } } From 069e95c2f14ba707fd790b5336a07c77f4eb94f2 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 23 Feb 2021 21:28:33 +0900 Subject: [PATCH 043/132] feat: 404 in guest/show_log --- app/Http/Controllers/GuestController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index 7ad666f8..11f0f696 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -99,6 +99,10 @@ public function exit(Request $request){ } public function show_log(Request $request, $id){ + $guest = Guest::find($id); + if(!$guest){ + abort(404); + } $logs = ActivityLog::query()->where('guest_id', $id)->get(); return response()->json(ActivityLogResource::collection($logs)); } From 8e4d3146e4fa68dd6b7cba3d319cf3297201ca03 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 23 Feb 2021 21:36:31 +0900 Subject: [PATCH 044/132] fix: exhroom/exit: remove duplicate validation --- app/Http/Controllers/ExhibitionRoomController.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/Http/Controllers/ExhibitionRoomController.php b/app/Http/Controllers/ExhibitionRoomController.php index 389244e0..bb947037 100644 --- a/app/Http/Controllers/ExhibitionRoomController.php +++ b/app/Http/Controllers/ExhibitionRoomController.php @@ -69,10 +69,6 @@ public function exit(Request $request){ 'guest_id' => ['string', 'required'] ]); - $this->validate($request, [ - 'guest_id' => ['string', 'required'] - ]); - $user_id = $request->user()->id; $guest = Guest::find($request->guest_id); $exh = ExhibitionRoom::find($user_id); From 581418c6c1208ecd798229a26bebcda6982185ca Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 23 Feb 2021 21:36:53 +0900 Subject: [PATCH 045/132] feat: exhibition/log --- app/Http/Controllers/ExhibitionRoomController.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/Http/Controllers/ExhibitionRoomController.php b/app/Http/Controllers/ExhibitionRoomController.php index bb947037..b3f28c58 100644 --- a/app/Http/Controllers/ExhibitionRoomController.php +++ b/app/Http/Controllers/ExhibitionRoomController.php @@ -88,4 +88,14 @@ public function exit(Request $request){ return response()->json(new GuestResource($guest)); } + + public function show_log(Request $request){ + $id = $request->user()->id; + $guest = ExhibitionRoom::find($id); + if(!$guest){ + abort(500, 'ExhibitionRoom Not found'); + } + $logs = ActivityLog::query()->where('exh_id', $id)->get(); + return response()->json($logs); + } } From e2a88bba5a2137e859df8fd7402df942023c71f9 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Wed, 24 Feb 2021 21:00:57 +0900 Subject: [PATCH 046/132] fix: set permission to general --- routes/web.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/routes/web.php b/routes/web.php index 4c7c2adf..bba4d995 100644 --- a/routes/web.php +++ b/routes/web.php @@ -46,12 +46,14 @@ $router->get('/onsite/reservation/{id}', ['uses' => 'ReservationController@show', 'middleware'=>'auth:reservation']); $router->get('/onsite/reservation/{id}/check', ['uses' => 'ReservationController@check', 'middleware'=>'auth:reservation,general']); -$router->get('/onsite/general/guest/', ['uses' => 'GuestController@index']); -$router->get('/onsite/general/guest/{id}', ['uses' => 'GuestController@show']); -$router->post('/onsite/general/enter', ['uses' => 'GuestController@enter']); -$router->post('/onsite/general/exit', ['uses' => 'GuestController@exit']); +$router->get('/onsite/general/guest/', ['uses' => 'GuestController@index', 'middleware'=>'auth:general']); +$router->get('/onsite/general/guest/{id}', ['uses' => 'GuestController@show', 'middleware'=>'auth:general']); +$router->get('/onsite/general/guest/{id}/log', ['uses' => 'GuestController@show_log', 'middleware'=>'auth:general']); +$router->post('/onsite/general/enter', ['uses' => 'GuestController@enter', 'middleware'=>'auth:general']); +$router->post('/onsite/general/exit', ['uses' => 'GuestController@exit', 'middleware'=>'auth:general']); $router->get('/onsite/exhibition/status/{id}', ['uses' => 'ExhibitionRoomController@show']); +$router->get('/onsite/exhibition/log', ['uses' => 'ExhibitionRoomController@show_log']); $router->post('/onsite/exhibition/enter', ['uses' => 'ExhibitionRoomController@enter']); $router->post('/onsite/exhibition/exit', ['uses' => 'ExhibitionRoomController@exit']); From 010ba50a3f5634ca7d88c4d539c4665511f63117 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Fri, 26 Feb 2021 23:10:25 +0900 Subject: [PATCH 047/132] feat: set permission to online/exhibition --- routes/web.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/routes/web.php b/routes/web.php index bba4d995..b576939b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -52,9 +52,9 @@ $router->post('/onsite/general/enter', ['uses' => 'GuestController@enter', 'middleware'=>'auth:general']); $router->post('/onsite/general/exit', ['uses' => 'GuestController@exit', 'middleware'=>'auth:general']); -$router->get('/onsite/exhibition/status/{id}', ['uses' => 'ExhibitionRoomController@show']); -$router->get('/onsite/exhibition/log', ['uses' => 'ExhibitionRoomController@show_log']); -$router->post('/onsite/exhibition/enter', ['uses' => 'ExhibitionRoomController@enter']); -$router->post('/onsite/exhibition/exit', ['uses' => 'ExhibitionRoomController@exit']); +$router->get('/onsite/exhibition/status/{id}', ['uses' => 'ExhibitionRoomController@show', 'middleware'=>'auth:exhibition']); +$router->get('/onsite/exhibition/log', ['uses' => 'ExhibitionRoomController@show_log', 'middleware'=>'auth:exhibition']); +$router->post('/onsite/exhibition/enter', ['uses' => 'ExhibitionRoomController@enter', 'middleware'=>'auth:exhibition']); +$router->post('/onsite/exhibition/exit', ['uses' => 'ExhibitionRoomController@exit', 'middleware'=>'auth:exhibition']); $router->options('{path:.*}', function(){}); // any path From 05b7ab13f6f8988a9ee59e53d5336753bcb41127 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 27 Feb 2021 23:42:02 +0900 Subject: [PATCH 048/132] feat: term controller --- app/Http/Controllers/TermController.php | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 app/Http/Controllers/TermController.php diff --git a/app/Http/Controllers/TermController.php b/app/Http/Controllers/TermController.php new file mode 100644 index 00000000..e5eb1e6a --- /dev/null +++ b/app/Http/Controllers/TermController.php @@ -0,0 +1,9 @@ + Date: Sun, 28 Feb 2021 16:09:46 +0900 Subject: [PATCH 049/132] refactor: remove unused implements --- app/Models/Guest.php | 8 +------- app/Models/Reservation.php | 8 +------- app/Models/Term.php | 8 +------- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/app/Models/Guest.php b/app/Models/Guest.php index f68654b8..257af9b4 100644 --- a/app/Models/Guest.php +++ b/app/Models/Guest.php @@ -2,16 +2,10 @@ namespace App\Models; -use Illuminate\Auth\Authenticatable; -use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; -use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Database\Eloquent\Model; -use Laravel\Lumen\Auth\Authorizable; -class Guest extends Model implements AuthenticatableContract, AuthorizableContract +class Guest extends Model { - use Authenticatable, Authorizable; - /** * The attributes that are mass assignable. * diff --git a/app/Models/Reservation.php b/app/Models/Reservation.php index 2dea91fd..dc23f97f 100644 --- a/app/Models/Reservation.php +++ b/app/Models/Reservation.php @@ -3,16 +3,10 @@ namespace App\Models; use Carbon\Carbon; -use Illuminate\Auth\Authenticatable; -use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; -use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Database\Eloquent\Model; -use Laravel\Lumen\Auth\Authorizable; -class Reservation extends Model implements AuthenticatableContract, AuthorizableContract +class Reservation extends Model { - use Authenticatable, Authorizable; - /** * The attributes that are mass assignable. * diff --git a/app/Models/Term.php b/app/Models/Term.php index cca2abdd..a6d1fe2f 100644 --- a/app/Models/Term.php +++ b/app/Models/Term.php @@ -2,16 +2,10 @@ namespace App\Models; -use Illuminate\Auth\Authenticatable; -use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; -use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Database\Eloquent\Model; -use Laravel\Lumen\Auth\Authorizable; -class Term extends Model implements AuthenticatableContract, AuthorizableContract +class Term extends Model { - use Authenticatable, Authorizable; - /** * The attributes that are mass assignable. * From 8fd4f144b6b4bf831a4a5ca17b92d4a481136b23 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 28 Feb 2021 16:10:07 +0900 Subject: [PATCH 050/132] refactor: remove unused import --- app/Http/Controllers/ExhibitionRoomController.php | 4 ---- app/Http/Controllers/GuestController.php | 3 --- app/Http/Resources/ExhibitionRoomResource.php | 1 - app/Models/ActivityLog.php | 8 +------- app/Models/ExhibitionRoom.php | 8 +------- 5 files changed, 2 insertions(+), 22 deletions(-) diff --git a/app/Http/Controllers/ExhibitionRoomController.php b/app/Http/Controllers/ExhibitionRoomController.php index b3f28c58..b865a02c 100644 --- a/app/Http/Controllers/ExhibitionRoomController.php +++ b/app/Http/Controllers/ExhibitionRoomController.php @@ -7,11 +7,7 @@ use App\Http\Resources\GuestResource; use App\Models\ExhibitionRoom; use App\Models\Guest; -use App\Models\Image; -use App\Models\Reservation; use Illuminate\Http\Request; -use Illuminate\Support\Str; -use App\SlackNotify; use Carbon\Carbon; use App\Models\ActivityLog; diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index 11f0f696..0c12214f 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -6,11 +6,8 @@ use App\Http\Resources\ActivityLogResource; use App\Http\Resources\GuestResource; use App\Models\Guest; -use App\Models\Image; use App\Models\Reservation; use Illuminate\Http\Request; -use Illuminate\Support\Str; -use App\SlackNotify; use Carbon\Carbon; use App\Models\ActivityLog; diff --git a/app/Http/Resources/ExhibitionRoomResource.php b/app/Http/Resources/ExhibitionRoomResource.php index 230d7bc5..fd090c23 100644 --- a/app/Http/Resources/ExhibitionRoomResource.php +++ b/app/Http/Resources/ExhibitionRoomResource.php @@ -2,7 +2,6 @@ namespace App\Http\Resources; -use App\Models\Term; use Illuminate\Http\Resources\Json\Resource; class ExhibitionRoomResource extends Resource diff --git a/app/Models/ActivityLog.php b/app/Models/ActivityLog.php index 7e79b124..bc010a68 100644 --- a/app/Models/ActivityLog.php +++ b/app/Models/ActivityLog.php @@ -2,16 +2,10 @@ namespace App\Models; -use Illuminate\Auth\Authenticatable; -use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; -use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Database\Eloquent\Model; -use Laravel\Lumen\Auth\Authorizable; -class ActivityLog extends Model implements AuthenticatableContract, AuthorizableContract +class ActivityLog extends Model { - use Authenticatable, Authorizable; - /** * The attributes that are mass assignable. * diff --git a/app/Models/ExhibitionRoom.php b/app/Models/ExhibitionRoom.php index c8c5c136..190b740b 100644 --- a/app/Models/ExhibitionRoom.php +++ b/app/Models/ExhibitionRoom.php @@ -2,16 +2,10 @@ namespace App\Models; -use Illuminate\Auth\Authenticatable; -use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; -use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Database\Eloquent\Model; -use Laravel\Lumen\Auth\Authorizable; -class ExhibitionRoom extends Model implements AuthenticatableContract, AuthorizableContract +class ExhibitionRoom extends Model { - use Authenticatable, Authorizable; - /** * The attributes that are mass assignable. * From 26fb0056db7d828c584c23a1b94d9b499330c999 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 28 Feb 2021 16:20:15 +0900 Subject: [PATCH 051/132] fix: remove message arg in Httpexception_with_error_code --- app/Exceptions/Handler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 06192d9d..175a9577 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -47,7 +47,7 @@ public function render($request, Exception $exception) { $request->headers->set('Accept', 'application/json'); if($exception instanceof HttpExceptionWithErrorCode){ - return response(['code'=>$exception->getStatusCode(), 'message'=>$exception->getMessage(), 'error_code'=>$exception->getErrorCode()], $exception->getStatusCode()); + return response(['code'=>$exception->getStatusCode(), 'error_code'=>$exception->getErrorCode()], $exception->getStatusCode()); } if($exception instanceof HttpException){ return response(['code'=>$exception->getStatusCode(), 'message'=>$exception->getMessage()], $exception->getStatusCode()); From 387c44babe5bd45f30dbbb2bf5f9c13d67558ca0 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 28 Feb 2021 16:23:40 +0900 Subject: [PATCH 052/132] style: make the if expression one line --- app/Http/Controllers/ExhibitionRoomController.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/Http/Controllers/ExhibitionRoomController.php b/app/Http/Controllers/ExhibitionRoomController.php index b865a02c..9c56bd61 100644 --- a/app/Http/Controllers/ExhibitionRoomController.php +++ b/app/Http/Controllers/ExhibitionRoomController.php @@ -43,9 +43,7 @@ public function enter(Request $request){ if($guest->exited_at !== NULL) throw new HttpExceptionWithErrorCode(400, 'GUEST_ALREADY_EXITED'); - if( - new Carbon($guest->term->exit_scheduled_time) < $current - ) + if(new Carbon($guest->term->exit_scheduled_time) < $current) throw new HttpExceptionWithErrorCode(400, 'EXIT_TIME_EXCEEDED'); From 49f69f37fe2f3804ce902cea0fb328541e78fe92 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 28 Feb 2021 16:30:43 +0900 Subject: [PATCH 053/132] style: remove unnessesary () --- app/Http/Controllers/GuestController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index 0c12214f..637e6954 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -23,7 +23,7 @@ public function show(Request $request, $id){ } public function index(){ - return response()->json(GuestResource::collection((Guest::all()))); + return response()->json(GuestResource::collection(Guest::all())); } public function enter(Request $request){ From 895dcc8bc0ac1decc3a9c957435e459fe8d9ee59 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 28 Feb 2021 16:32:08 +0900 Subject: [PATCH 054/132] refactor: rename reserv to reservation --- app/Http/Controllers/GuestController.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index 637e6954..8ebed3be 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -36,21 +36,21 @@ public function enter(Request $request){ throw new HttpExceptionWithErrorCode(400, 'INVALID_WRISTBAND_CODE'); } - $reserv = Reservation::find($request->reservation_id); + $reservation = Reservation::find($request->reservation_id); - if(!$reserv) throw new HttpExceptionWithErrorCode(400, 'RESERVATION_NOT_FOUND'); + if(!$reservation) throw new HttpExceptionWithErrorCode(400, 'RESERVATION_NOT_FOUND'); - $reserv_res = $reserv->hasProblem(); + $reservation_res = $reservation->hasProblem(); - if($reserv_res !== false){ - throw new HttpExceptionWithErrorCode(400, $reserv_res); + if($reservation_res !== false){ + throw new HttpExceptionWithErrorCode(400, $reservation_res); } if(Guest::find($request->guest_id)) { throw new HttpExceptionWithErrorCode(400, 'ALREADY_USED_WRISTBAND'); } - $term = $reserv->term; + $term = $reservation->term; if( !preg_match( @@ -71,7 +71,7 @@ public function enter(Request $request){ ); // TODO: 複数人で処理するときの扱いを考える (docsの編集待ち) - $reserv->update(['guest_id' => $guest->id]); + $reservation->update(['guest_id' => $guest->id]); return response()->json(new GuestResource($guest)); } From 0eeebebcfad983cc911b68f92a9eabae5b559f96 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 28 Feb 2021 16:56:06 +0900 Subject: [PATCH 055/132] refactor: use strpos instead of regex --- app/Http/Controllers/GuestController.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index 8ebed3be..7a97fbc1 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -53,10 +53,7 @@ public function enter(Request $request){ $term = $reservation->term; if( - !preg_match( - '/^'.config('manage.colors')[$term->color_id]['prefix'].'/', - $request->guest_id - ) + strpos($request->guest_id, config('manage.colors')[$term->color_id]['prefix']) !== 0 ) { throw new HttpExceptionWithErrorCode(400, 'WRONG_WRISTBAND_COLOR'); } From 720a5bd726ccfef37baaebad3baacadde53ee034 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 28 Feb 2021 17:00:12 +0900 Subject: [PATCH 056/132] fix: stop quitting writing php with adding = in != --- app/Http/Controllers/GuestController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index 7a97fbc1..4401cedb 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -83,7 +83,7 @@ public function exit(Request $request){ abort(404); } - if($guest->exited_at != NULL) { + if($guest->exited_at !== NULL) { abort(409); } From 90fb8153ace435944b5669d9488db0390736e4dd Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 28 Feb 2021 17:21:57 +0900 Subject: [PATCH 057/132] fix: remove unused expression --- app/Http/Controllers/ReservationController.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/ReservationController.php b/app/Http/Controllers/ReservationController.php index 562a2573..f84274d0 100644 --- a/app/Http/Controllers/ReservationController.php +++ b/app/Http/Controllers/ReservationController.php @@ -23,11 +23,8 @@ public function index(Request $request) { $response = Reservation::query(); - foreach ($query as $i => $value){ - if ($i === 'q')continue; - if ($i === 'author_id')continue; - $response->where($i, $value); - } + foreach ($query as $i => $value) $response->where($i, $value); + return response(ReservationResource::collection($response->get())); } @@ -64,7 +61,7 @@ public function show($id) { public function check($id) { $reservation = Reservation::find($id); if(!$reservation) abort(404); - + $status_code = $reservation->hasProblem(); if($status_code !== false) { $valid = false; From 7d57f3a274287ce0588dc7e47e5596572785ddb8 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 28 Feb 2021 17:27:47 +0900 Subject: [PATCH 058/132] fix: rename to clarify method usage --- app/Http/Controllers/GuestController.php | 6 +++--- app/Models/Reservation.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index 4401cedb..f3e8114b 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -40,10 +40,10 @@ public function enter(Request $request){ if(!$reservation) throw new HttpExceptionWithErrorCode(400, 'RESERVATION_NOT_FOUND'); - $reservation_res = $reservation->hasProblem(); + $reservation_error_code = $reservation->getErrorCode(); - if($reservation_res !== false){ - throw new HttpExceptionWithErrorCode(400, $reservation_res); + if($reservation_error_code !== null){ + throw new HttpExceptionWithErrorCode(400, $reservation_error_code); } if(Guest::find($request->guest_id)) { diff --git a/app/Models/Reservation.php b/app/Models/Reservation.php index dc23f97f..19756280 100644 --- a/app/Models/Reservation.php +++ b/app/Models/Reservation.php @@ -39,7 +39,7 @@ public function term() { return $this->belongsTo('\App\Models\Term'); } - public function hasProblem() { + public function getErrorCode() { $term = $this->term; $current = Carbon::now(); @@ -54,6 +54,6 @@ public function hasProblem() { return 'ALREADY_ENTERED_RESERVATION'; } - return false; + return null; } } From 3c4665813675831e4343af07771520a51ca141f2 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 28 Feb 2021 17:31:12 +0900 Subject: [PATCH 059/132] refactor: use do-while in generating reservation-id --- app/Http/Controllers/ReservationController.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/ReservationController.php b/app/Http/Controllers/ReservationController.php index f84274d0..474a2941 100644 --- a/app/Http/Controllers/ReservationController.php +++ b/app/Http/Controllers/ReservationController.php @@ -38,11 +38,9 @@ public function create(Request $request) { 'cellphone' => ['required', 'string', 'regex:/0\d{9,10}$/'] ]); - $reservation_id = 'R-'.Str::random(10); - while(true){ - if(!Reservation::where('id', $reservation_id)->exists()) break; + do { $reservation_id = 'R-'.Str::random(10); - } + } while(Reservation::where('id', $reservation_id)->exists()); $reservation = Reservation::create( array_merge($body, ['id' => $reservation_id]) From 993931903fd4a6ca8d8ac2f918ca4685c889e11f Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 28 Feb 2021 17:32:09 +0900 Subject: [PATCH 060/132] fix: remove unused method in guest resource --- app/Http/Resources/GuestResource.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/Http/Resources/GuestResource.php b/app/Http/Resources/GuestResource.php index 144a6b6c..3748eda9 100644 --- a/app/Http/Resources/GuestResource.php +++ b/app/Http/Resources/GuestResource.php @@ -24,12 +24,4 @@ public function toArray($request) 'exh_id' =>$this->exh_id, ]; } - - private function removeWrap($title) { - $res = $title; - $res = rawurldecode($res); - $res = str_replace("%0A", '', $res); - $res = str_replace("\\n", '', $res); - return $res; - } } From ac2926234a02a5ba4883754ba23079d9802da7f5 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 28 Feb 2021 17:36:38 +0900 Subject: [PATCH 061/132] fix: to accept enter when the time as same as enter_scheduled_time --- app/Models/Reservation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/Reservation.php b/app/Models/Reservation.php index 19756280..9f511cd7 100644 --- a/app/Models/Reservation.php +++ b/app/Models/Reservation.php @@ -44,7 +44,7 @@ public function getErrorCode() { $current = Carbon::now(); if( - new Carbon($term->enter_scheduled_time) > $current + new Carbon($term->enter_scheduled_time) >= $current || new Carbon($term->exit_scheduled_time) < $current ) { return 'OUT_OF_RESERVATION_TIME'; From 9b78368f4f3a3f1f0c324fde9adc0c8a00d56994 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 28 Feb 2021 17:46:13 +0900 Subject: [PATCH 062/132] refactor: rename config/manage to config/onsite --- app/Http/Controllers/GuestController.php | 2 +- bootstrap/app.php | 2 +- config/{manage.php => onsite.php} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename config/{manage.php => onsite.php} (100%) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index f3e8114b..4ecf91de 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -53,7 +53,7 @@ public function enter(Request $request){ $term = $reservation->term; if( - strpos($request->guest_id, config('manage.colors')[$term->color_id]['prefix']) !== 0 + strpos($request->guest_id, config('onsite.colors')[$term->color_id]['prefix']) !== 0 ) { throw new HttpExceptionWithErrorCode(400, 'WRONG_WRISTBAND_COLOR'); } diff --git a/bootstrap/app.php b/bootstrap/app.php index 86582a0a..fda64490 100755 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -101,6 +101,6 @@ }); $app->configure('blog'); -$app->configure('manage'); +$app->configure('onsite'); return $app; diff --git a/config/manage.php b/config/onsite.php similarity index 100% rename from config/manage.php rename to config/onsite.php From b6c0a33f9b2aadbbbb123262085ab08a21ff3abe Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 28 Feb 2021 18:06:43 +0900 Subject: [PATCH 063/132] refactor: use group in router --- routes/web.php | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/routes/web.php b/routes/web.php index b576939b..70daae65 100644 --- a/routes/web.php +++ b/routes/web.php @@ -41,20 +41,30 @@ $router->get('/ogimage/articles/{id}', ['uses' => 'OGImageController@getArticleImage']); $router->get('/ogimage/preview', ['uses' => 'OGImageController@getPreview']); -$router->post('/onsite/reservation', ['uses' => 'ReservationController@create']); -$router->get('/onsite/reservation/search', ['uses' => 'ReservationController@index', 'middleware'=>'auth:reservation']); -$router->get('/onsite/reservation/{id}', ['uses' => 'ReservationController@show', 'middleware'=>'auth:reservation']); -$router->get('/onsite/reservation/{id}/check', ['uses' => 'ReservationController@check', 'middleware'=>'auth:reservation,general']); - -$router->get('/onsite/general/guest/', ['uses' => 'GuestController@index', 'middleware'=>'auth:general']); -$router->get('/onsite/general/guest/{id}', ['uses' => 'GuestController@show', 'middleware'=>'auth:general']); -$router->get('/onsite/general/guest/{id}/log', ['uses' => 'GuestController@show_log', 'middleware'=>'auth:general']); -$router->post('/onsite/general/enter', ['uses' => 'GuestController@enter', 'middleware'=>'auth:general']); -$router->post('/onsite/general/exit', ['uses' => 'GuestController@exit', 'middleware'=>'auth:general']); - -$router->get('/onsite/exhibition/status/{id}', ['uses' => 'ExhibitionRoomController@show', 'middleware'=>'auth:exhibition']); -$router->get('/onsite/exhibition/log', ['uses' => 'ExhibitionRoomController@show_log', 'middleware'=>'auth:exhibition']); -$router->post('/onsite/exhibition/enter', ['uses' => 'ExhibitionRoomController@enter', 'middleware'=>'auth:exhibition']); -$router->post('/onsite/exhibition/exit', ['uses' => 'ExhibitionRoomController@exit', 'middleware'=>'auth:exhibition']); +$router->group(['prefix' => 'onsite'], function() use ($router) { + $router->group(['prefix' => 'reservation'], function () use ($router) { + $router->post('/', ['uses' => 'Controller@create']); + $router->get('search', ['uses' => 'Controller@index', 'middleware' => 'auth:reservation']); + $router->get('{id}', ['uses' => 'Controller@show', 'middleware' => 'auth:reservation']); + $router->get('{id}/check', ['uses' => 'ReservationController@check', 'middleware' => 'auth:reservation,general']); + }); + + $router->group(['prefix' => 'general', 'middleware' => 'auth:general'], function () use ($router) { + $router->get('guest/', ['uses' => 'GuestController@index']); + $router->get('guest/{id}', ['uses' => 'GuestController@show']); + $router->get('guest/{id}/log', ['uses' => 'GuestController@show_log']); + $router->post('enter', ['uses' => 'GuestController@enter']); + $router->post('exit', ['uses' => 'GuestController@exit']); + // TODO: term + }); + + $router->group(['prefix' => 'exhibition'], function () use ($router) { + $router->get('status/{id}', ['uses' => 'ExhibitionRoomController@show', 'middleware' => 'auth:exhibition']); + $router->get('status', ['uses' => 'ExhibitionRoomController@index', 'middleware' => 'auth:exhibition,general']); + $router->get('log', ['uses' => 'ExhibitionRoomController@show_log', 'middleware' => 'auth:exhibition']); + $router->post('enter', ['uses' => 'ExhibitionRoomController@enter', 'middleware' => 'auth:exhibition']); + $router->post('exit', ['uses' => 'ExhibitionRoomController@exit', 'middleware' => 'auth:exhibition']); + }); +}); $router->options('{path:.*}', function(){}); // any path From d4fade3eda5769f92d6692ff52abf3eaad0af833 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 2 Mar 2021 01:07:13 +0900 Subject: [PATCH 064/132] refactor: fix by phpcbf / phpcs --- app/Exceptions/Handler.php | 12 ++++---- app/Exceptions/HttpExceptionWithErrorCode.php | 5 ++-- .../Controllers/ExhibitionRoomController.php | 27 ++++++++--------- app/Http/Controllers/GuestController.php | 30 +++++++++---------- .../Controllers/ReservationController.php | 13 ++++---- app/Http/Controllers/TermController.php | 3 +- app/Http/Resources/ActivityLogResource.php | 7 ++--- app/Http/Resources/ExhibitionRoomResource.php | 7 ++--- app/Http/Resources/GuestResource.php | 7 ++--- app/Http/Resources/ReservationResource.php | 7 ++--- .../ReservationWithPrivateResource.php | 7 ++--- app/Models/ActivityLog.php | 7 ++--- app/Models/ExhibitionRoom.php | 12 ++++---- app/Models/Guest.php | 7 ++--- app/Models/Reservation.php | 9 +++--- app/Models/Term.php | 6 ++-- routes/web.php | 6 ++-- 17 files changed, 79 insertions(+), 93 deletions(-) diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 8a4f6c1a..88cee479 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -44,16 +44,16 @@ public function report(Exception $exception) { */ public function render($request, Exception $exception) { $request->headers->set('Accept', 'application/json'); - if($exception instanceof HttpExceptionWithErrorCode){ + if ($exception instanceof HttpExceptionWithErrorCode) { return response([ - 'code'=>$exception->getStatusCode(), - 'error_code'=>$exception->getErrorCode() + 'code'=>$exception->getStatusCode(), + 'error_code'=>$exception->getErrorCode() ], $exception->getStatusCode()); } - if($exception instanceof HttpException){ + if ($exception instanceof HttpException) { return response([ - 'code'=>$exception->getStatusCode(), - 'message'=>$exception->getMessage() + 'code'=>$exception->getStatusCode(), + 'message'=>$exception->getMessage() ], $exception->getStatusCode()); } if ($exception instanceof ValidationException) { diff --git a/app/Exceptions/HttpExceptionWithErrorCode.php b/app/Exceptions/HttpExceptionWithErrorCode.php index c05b0a1c..f757dae8 100644 --- a/app/Exceptions/HttpExceptionWithErrorCode.php +++ b/app/Exceptions/HttpExceptionWithErrorCode.php @@ -2,8 +2,8 @@ namespace App\Exceptions; -use Symfony\Component\HttpKernel\Exception\HttpException; +use Symfony\Component\HttpKernel\Exception\HttpException; class HttpExceptionWithErrorCode extends HttpException { private $errorCode; @@ -14,8 +14,7 @@ public function __construct($httpCode, $errorCode) { parent::__construct($httpCode); } - public function getErrorCode() - { + public function getErrorCode() { return $this->errorCode; } } diff --git a/app/Http/Controllers/ExhibitionRoomController.php b/app/Http/Controllers/ExhibitionRoomController.php index 9c56bd61..e3efca11 100644 --- a/app/Http/Controllers/ExhibitionRoomController.php +++ b/app/Http/Controllers/ExhibitionRoomController.php @@ -11,18 +11,17 @@ use Carbon\Carbon; use App\Models\ActivityLog; - class ExhibitionRoomController extends Controller { - public function show(Request $request, $id){ + public function show(Request $request, $id) { $exhibition = ExhibitionRoom::find($id); - if(!$exhibition){ + if (!$exhibition) { abort(404); } return response()->json(new ExhibitionRoomResource($exhibition)); } - public function enter(Request $request){ + public function enter(Request $request) { $this->validate($request, [ 'guest_id' => ['string', 'required'] ]); @@ -32,18 +31,18 @@ public function enter(Request $request){ $exh = ExhibitionRoom::find($user_id); $current = Carbon::now(); - if(!$guest) throw new HttpExceptionWithErrorCode(400, 'GUEST_NOT_FOUND'); + if (!$guest) throw new HttpExceptionWithErrorCode(400, 'GUEST_NOT_FOUND'); - if($guest->exh_id === $user_id) + if ($guest->exh_id === $user_id) throw new HttpExceptionWithErrorCode(400, 'GUEST_ALREADY_ENTERED'); - if($exh->capacity === $exh->guest_count) + if ($exh->capacity === $exh->guest_count) throw new HttpExceptionWithErrorCode(400, 'PEOPLE_LIMIT_EXCEEDED'); - if($guest->exited_at !== NULL) + if ($guest->exited_at !== null) throw new HttpExceptionWithErrorCode(400, 'GUEST_ALREADY_EXITED'); - if(new Carbon($guest->term->exit_scheduled_time) < $current) + if (new Carbon($guest->term->exit_scheduled_time) < $current) throw new HttpExceptionWithErrorCode(400, 'EXIT_TIME_EXCEEDED'); @@ -58,7 +57,7 @@ public function enter(Request $request){ return response()->json(new GuestResource($guest)); } - public function exit(Request $request){ + public function exit(Request $request) { $this->validate($request, [ 'guest_id' => ['string', 'required'] ]); @@ -67,9 +66,9 @@ public function exit(Request $request){ $guest = Guest::find($request->guest_id); $exh = ExhibitionRoom::find($user_id); - if(!$guest) throw new HttpExceptionWithErrorCode(400, 'GUEST_NOT_FOUND'); + if (!$guest) throw new HttpExceptionWithErrorCode(400, 'GUEST_NOT_FOUND'); - if($guest->exited_at !== NULL) + if ($guest->exited_at !== null) throw new HttpExceptionWithErrorCode(400, 'GUEST_ALREADY_EXITED'); $guest->update(['exh_id' => null]); @@ -83,10 +82,10 @@ public function exit(Request $request){ return response()->json(new GuestResource($guest)); } - public function show_log(Request $request){ + public function showLog(Request $request) { $id = $request->user()->id; $guest = ExhibitionRoom::find($id); - if(!$guest){ + if (!$guest) { abort(500, 'ExhibitionRoom Not found'); } $logs = ActivityLog::query()->where('exh_id', $id)->get(); diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index 4ecf91de..c800d0d7 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -11,49 +11,47 @@ use Carbon\Carbon; use App\Models\ActivityLog; - class GuestController extends Controller { - public function show(Request $request, $id){ + public function show(Request $request, $id) { $guest = Guest::find($id); - if(!$guest){ + if (!$guest) { abort(404); } return response()->json(new GuestResource($guest)); } - public function index(){ + public function index() { return response()->json(GuestResource::collection(Guest::all())); } - public function enter(Request $request){ + public function enter(Request $request) { $this->validate($request, [ 'reservation_id' => ['string', 'required'], 'guest_id' => ['string', 'required'] ]); - if(!preg_match('/^[A-Z]{2,3}-[a-zA-Z0-9]{5}$/', $request->guest_id)){ + if (!preg_match('/^[A-Z]{2,3}-[a-zA-Z0-9]{5}$/', $request->guest_id)) { throw new HttpExceptionWithErrorCode(400, 'INVALID_WRISTBAND_CODE'); } $reservation = Reservation::find($request->reservation_id); - if(!$reservation) throw new HttpExceptionWithErrorCode(400, 'RESERVATION_NOT_FOUND'); + if (!$reservation) throw new HttpExceptionWithErrorCode(400, 'RESERVATION_NOT_FOUND'); $reservation_error_code = $reservation->getErrorCode(); - if($reservation_error_code !== null){ + if ($reservation_error_code !== null) { throw new HttpExceptionWithErrorCode(400, $reservation_error_code); } - if(Guest::find($request->guest_id)) { + if (Guest::find($request->guest_id)) { throw new HttpExceptionWithErrorCode(400, 'ALREADY_USED_WRISTBAND'); } $term = $reservation->term; - if( - strpos($request->guest_id, config('onsite.colors')[$term->color_id]['prefix']) !== 0 + if (strpos($request->guest_id, config('onsite.colors')[$term->color_id]['prefix']) !== 0 ) { throw new HttpExceptionWithErrorCode(400, 'WRONG_WRISTBAND_COLOR'); } @@ -73,17 +71,17 @@ public function enter(Request $request){ return response()->json(new GuestResource($guest)); } - public function exit(Request $request){ + public function exit(Request $request) { $this->validate($request, [ 'guest_id' => ['string', 'required'] ]); $guest = Guest::find($request->guest_id); - if(!$guest) { + if (!$guest) { abort(404); } - if($guest->exited_at !== NULL) { + if ($guest->exited_at !== null) { abort(409); } @@ -92,9 +90,9 @@ public function exit(Request $request){ return response()->json(new GuestResource($guest)); } - public function show_log(Request $request, $id){ + public function showLog(Request $request, $id) { $guest = Guest::find($id); - if(!$guest){ + if (!$guest) { abort(404); } $logs = ActivityLog::query()->where('guest_id', $id)->get(); diff --git a/app/Http/Controllers/ReservationController.php b/app/Http/Controllers/ReservationController.php index 474a2941..7b7b64d4 100644 --- a/app/Http/Controllers/ReservationController.php +++ b/app/Http/Controllers/ReservationController.php @@ -8,7 +8,6 @@ use Illuminate\Http\Request; use \Illuminate\Support\Str; - class ReservationController extends Controller { public function index(Request $request) { @@ -40,30 +39,30 @@ public function create(Request $request) { do { $reservation_id = 'R-'.Str::random(10); - } while(Reservation::where('id', $reservation_id)->exists()); + } while (Reservation::where('id', $reservation_id)->exists()); $reservation = Reservation::create( array_merge($body, ['id' => $reservation_id]) ); - return response($reservation,201); + return response($reservation, 201); } public function show($id) { $reservation = Reservation::find($id); - if(!$reservation) abort(404); + if (!$reservation) abort(404); return response()->json(new ReservationWithPrivateResource($reservation)); } public function check($id) { $reservation = Reservation::find($id); - if(!$reservation) abort(404); + if (!$reservation) abort(404); $status_code = $reservation->hasProblem(); - if($status_code !== false) { + if ($status_code !== false) { $valid = false; - }else{ + } else { $valid = true; $status_code = null; } diff --git a/app/Http/Controllers/TermController.php b/app/Http/Controllers/TermController.php index e5eb1e6a..11a35900 100644 --- a/app/Http/Controllers/TermController.php +++ b/app/Http/Controllers/TermController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers; class TermController extends Controller { - public function index(){ - + public function index() { } } diff --git a/app/Http/Resources/ActivityLogResource.php b/app/Http/Resources/ActivityLogResource.php index 946c0c39..beeea697 100644 --- a/app/Http/Resources/ActivityLogResource.php +++ b/app/Http/Resources/ActivityLogResource.php @@ -4,16 +4,15 @@ use Illuminate\Http\Resources\Json\Resource; -class ActivityLogResource extends Resource -{ +class ActivityLogResource extends Resource { + /** * リソースを配列へ変換する * * @param \Illuminate\Http\Request * @return array */ - public function toArray($request) - { + public function toArray($request) { return [ 'id' => $this->id, 'timestamp' => $this->timestamp->toIso8601ZuluString(), diff --git a/app/Http/Resources/ExhibitionRoomResource.php b/app/Http/Resources/ExhibitionRoomResource.php index fd090c23..dd3676a1 100644 --- a/app/Http/Resources/ExhibitionRoomResource.php +++ b/app/Http/Resources/ExhibitionRoomResource.php @@ -4,16 +4,15 @@ use Illuminate\Http\Resources\Json\Resource; -class ExhibitionRoomResource extends Resource -{ +class ExhibitionRoomResource extends Resource { + /** * リソースを配列へ変換する * * @param \Illuminate\Http\Request * @return array */ - public function toArray($request) - { + public function toArray($request) { return [ 'count' => $this->countGuest(), 'limit' => $this->capacity, diff --git a/app/Http/Resources/GuestResource.php b/app/Http/Resources/GuestResource.php index 3748eda9..393c0406 100644 --- a/app/Http/Resources/GuestResource.php +++ b/app/Http/Resources/GuestResource.php @@ -4,16 +4,15 @@ use Illuminate\Http\Resources\Json\Resource; -class GuestResource extends Resource -{ +class GuestResource extends Resource { + /** * リソースを配列へ変換する * * @param \Illuminate\Http\Request * @return array */ - public function toArray($request) - { + public function toArray($request) { return [ 'id' => $this->id, 'color_id' => $this->term->color_id, diff --git a/app/Http/Resources/ReservationResource.php b/app/Http/Resources/ReservationResource.php index 49072578..2a539cf2 100644 --- a/app/Http/Resources/ReservationResource.php +++ b/app/Http/Resources/ReservationResource.php @@ -4,16 +4,15 @@ use Illuminate\Http\Resources\Json\Resource; -class ReservationResource extends Resource -{ +class ReservationResource extends Resource { + /** * リソースを配列へ変換する * * @param \Illuminate\Http\Request * @return array */ - public function toArray($request) - { + public function toArray($request) { return [ 'id' => $this->id, 'email' => $this->email, diff --git a/app/Http/Resources/ReservationWithPrivateResource.php b/app/Http/Resources/ReservationWithPrivateResource.php index 1a7901a8..7d669f62 100644 --- a/app/Http/Resources/ReservationWithPrivateResource.php +++ b/app/Http/Resources/ReservationWithPrivateResource.php @@ -4,16 +4,15 @@ use Illuminate\Http\Resources\Json\Resource; -class ReservationWithPrivateResource extends Resource -{ +class ReservationWithPrivateResource extends Resource { + /** * リソースを配列へ変換する * * @param \Illuminate\Http\Request * @return array */ - public function toArray($request) - { + public function toArray($request) { return [ 'id' => $this->id, 'email' => $this->email, diff --git a/app/Models/ActivityLog.php b/app/Models/ActivityLog.php index bc010a68..117b97d7 100644 --- a/app/Models/ActivityLog.php +++ b/app/Models/ActivityLog.php @@ -4,15 +4,15 @@ use Illuminate\Database\Eloquent\Model; -class ActivityLog extends Model -{ +class ActivityLog extends Model { + /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ - 'id', 'timestamp', 'exh_id', 'log_type', 'guest_id' + 'id', 'timestamp', 'exh_id', 'log_type', 'guest_id', ]; /** @@ -37,5 +37,4 @@ class ActivityLog extends Model public function guest() { return $this->belongsTo('\App\Models\Guest'); } - } diff --git a/app/Models/ExhibitionRoom.php b/app/Models/ExhibitionRoom.php index 190b740b..4d2e5c28 100644 --- a/app/Models/ExhibitionRoom.php +++ b/app/Models/ExhibitionRoom.php @@ -4,8 +4,8 @@ use Illuminate\Database\Eloquent\Model; -class ExhibitionRoom extends Model -{ +class ExhibitionRoom extends Model { + /** * The attributes that are mass assignable. * @@ -13,7 +13,7 @@ class ExhibitionRoom extends Model */ protected $fillable = [ - 'id', 'room_id', 'capacity', 'guest_count', 'updated_at' + 'id', 'room_id', 'capacity', 'guest_count', 'updated_at', ]; /** @@ -42,10 +42,10 @@ public function guests() { public function countGuest() { $terms = Term::all(); $res = []; - foreach($terms as $term){ - $guest = $this->guests->where('term_id',$term->id); + foreach ($terms as $term) { + $guest = $this->guests->where('term_id', $term->id); $count = count($guest); - if($count==0) continue; + if ($count==0) continue; $res[$term->id] = $count; } return $res; diff --git a/app/Models/Guest.php b/app/Models/Guest.php index 257af9b4..5b6b00b8 100644 --- a/app/Models/Guest.php +++ b/app/Models/Guest.php @@ -4,15 +4,15 @@ use Illuminate\Database\Eloquent\Model; -class Guest extends Model -{ +class Guest extends Model { + /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ - 'id', 'entered_at', 'exited_at', 'exh_id', 'term_id', 'reservation_id' + 'id', 'entered_at', 'exited_at', 'exh_id', 'term_id', 'reservation_id', ]; /** @@ -45,5 +45,4 @@ public function logs() { public function term() { return $this->belongsTo('\App\Models\Term'); } - } diff --git a/app/Models/Reservation.php b/app/Models/Reservation.php index 9f511cd7..4c80af18 100644 --- a/app/Models/Reservation.php +++ b/app/Models/Reservation.php @@ -5,8 +5,8 @@ use Carbon\Carbon; use Illuminate\Database\Eloquent\Model; -class Reservation extends Model -{ +class Reservation extends Model { + /** * The attributes that are mass assignable. * @@ -43,14 +43,13 @@ public function getErrorCode() { $term = $this->term; $current = Carbon::now(); - if( - new Carbon($term->enter_scheduled_time) >= $current + if (new Carbon($term->enter_scheduled_time) >= $current || new Carbon($term->exit_scheduled_time) < $current ) { return 'OUT_OF_RESERVATION_TIME'; } - if($this->guest_id !== NULL){ + if ($this->guest_id !== null) { return 'ALREADY_ENTERED_RESERVATION'; } diff --git a/app/Models/Term.php b/app/Models/Term.php index a6d1fe2f..ca944a59 100644 --- a/app/Models/Term.php +++ b/app/Models/Term.php @@ -4,15 +4,15 @@ use Illuminate\Database\Eloquent\Model; -class Term extends Model -{ +class Term extends Model { + /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ - 'id', 'enter_scheduled_time', 'exit_scheduled_time', 'color_id' + 'id', 'enter_scheduled_time', 'exit_scheduled_time', 'color_id', ]; /** diff --git a/routes/web.php b/routes/web.php index 3bb6a978..14ef3d42 100644 --- a/routes/web.php +++ b/routes/web.php @@ -42,7 +42,7 @@ $router->get('/ogimage/articles/{id}', ['uses' => 'OGImageController@getArticleImage']); $router->get('/ogimage/preview', ['uses' => 'OGImageController@getPreview']); -$router->group(['prefix' => 'onsite'], function() use ($router) { +$router->group(['prefix' => 'onsite'], function () use ($router) { $router->group(['prefix' => 'reservation'], function () use ($router) { $router->post('/', ['uses' => 'Controller@create']); $router->get('search', ['uses' => 'Controller@index', 'middleware' => 'auth:reservation']); @@ -53,7 +53,7 @@ $router->group(['prefix' => 'general', 'middleware' => 'auth:general'], function () use ($router) { $router->get('guest/', ['uses' => 'GuestController@index']); $router->get('guest/{id}', ['uses' => 'GuestController@show']); - $router->get('guest/{id}/log', ['uses' => 'GuestController@show_log']); + $router->get('guest/{id}/log', ['uses' => 'GuestController@showLog']); $router->post('enter', ['uses' => 'GuestController@enter']); $router->post('exit', ['uses' => 'GuestController@exit']); // TODO: term @@ -62,7 +62,7 @@ $router->group(['prefix' => 'exhibition'], function () use ($router) { $router->get('status/{id}', ['uses' => 'ExhibitionRoomController@show', 'middleware' => 'auth:exhibition']); $router->get('status', ['uses' => 'ExhibitionRoomController@index', 'middleware' => 'auth:exhibition,general']); - $router->get('log', ['uses' => 'ExhibitionRoomController@show_log', 'middleware' => 'auth:exhibition']); + $router->get('log', ['uses' => 'ExhibitionRoomController@showLog', 'middleware' => 'auth:exhibition']); $router->post('enter', ['uses' => 'ExhibitionRoomController@enter', 'middleware' => 'auth:exhibition']); $router->post('exit', ['uses' => 'ExhibitionRoomController@exit', 'middleware' => 'auth:exhibition']); }); From b4c8b725b83bcb933769f4440d7ee62253926d6a Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 2 Mar 2021 22:55:08 +0900 Subject: [PATCH 065/132] feat: exhibition room controller index --- .../Controllers/ExhibitionRoomController.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/Http/Controllers/ExhibitionRoomController.php b/app/Http/Controllers/ExhibitionRoomController.php index e3efca11..15f8e865 100644 --- a/app/Http/Controllers/ExhibitionRoomController.php +++ b/app/Http/Controllers/ExhibitionRoomController.php @@ -12,6 +12,22 @@ use App\Models\ActivityLog; class ExhibitionRoomController extends Controller { + public function index() { + $exh_status = ExhibitionRoom::all(); + $terms = array(); + foreach ($exh_status as $exh) { + $exh_term = $exh->countGuest(); + foreach ($exh_term as $id => $count) { + if (isset($terms[$id])) $terms[$id] += $count; + else $terms[$id] = $count; + } + } + return response()->json([ + 'exh' => $exh_status, + 'all' => $terms + ]); + } + public function show(Request $request, $id) { $exhibition = ExhibitionRoom::find($id); if (!$exhibition) { From 669926ebe73c522e4bf2d9db3ab028ff8326c04b Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Thu, 4 Mar 2021 14:58:33 +0900 Subject: [PATCH 066/132] fix: use getErrorCode --- app/Http/Controllers/ReservationController.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/ReservationController.php b/app/Http/Controllers/ReservationController.php index 7b7b64d4..d970b7e7 100644 --- a/app/Http/Controllers/ReservationController.php +++ b/app/Http/Controllers/ReservationController.php @@ -59,12 +59,11 @@ public function check($id) { $reservation = Reservation::find($id); if (!$reservation) abort(404); - $status_code = $reservation->hasProblem(); - if ($status_code !== false) { + $status_code = $reservation->getErrorCode(); + if ($status_code !== null) { $valid = false; } else { $valid = true; - $status_code = null; } $res = [ From 6a226ad8d4396de0373097d6c17ed4b48761c645 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Thu, 4 Mar 2021 14:58:57 +0900 Subject: [PATCH 067/132] fix: use correct controller --- routes/web.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/routes/web.php b/routes/web.php index 14ef3d42..93ed0e2b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -44,9 +44,9 @@ $router->group(['prefix' => 'onsite'], function () use ($router) { $router->group(['prefix' => 'reservation'], function () use ($router) { - $router->post('/', ['uses' => 'Controller@create']); - $router->get('search', ['uses' => 'Controller@index', 'middleware' => 'auth:reservation']); - $router->get('{id}', ['uses' => 'Controller@show', 'middleware' => 'auth:reservation']); + $router->post('/', ['uses' => 'ReservationController@create']); + $router->get('search', ['uses' => 'ReservationController@index', 'middleware' => 'auth:reservation']); + $router->get('{id}', ['uses' => 'ReservationController@show', 'middleware' => 'auth:reservation']); $router->get('{id}/check', ['uses' => 'ReservationController@check', 'middleware' => 'auth:reservation,general']); }); From f006c59c452b485aed83f1386a1a8fb3ad371fc7 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Fri, 5 Mar 2021 14:11:37 +0900 Subject: [PATCH 068/132] feat: term index --- app/Http/Controllers/TermController.php | 13 +++++++++++++ routes/web.php | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/TermController.php b/app/Http/Controllers/TermController.php index 11a35900..d6c5d47a 100644 --- a/app/Http/Controllers/TermController.php +++ b/app/Http/Controllers/TermController.php @@ -2,7 +2,20 @@ namespace App\Http\Controllers; +use App\Models\Term; + class TermController extends Controller { public function index() { + $terms = Term::all(); + $result = []; + foreach ($terms as $term) { + $result[$term->id] = [ + "enter_scheduled_time" => $term->enter_scheduled_time, + "exit_scheduled_time" => $term->exit_scheduled_time, + "color_id" => $term->color_id + ]; + } + + return response()->json($result); } } diff --git a/routes/web.php b/routes/web.php index 93ed0e2b..867b5cba 100644 --- a/routes/web.php +++ b/routes/web.php @@ -56,7 +56,7 @@ $router->get('guest/{id}/log', ['uses' => 'GuestController@showLog']); $router->post('enter', ['uses' => 'GuestController@enter']); $router->post('exit', ['uses' => 'GuestController@exit']); - // TODO: term + $router->get('term', ['uses' => 'TermController@index']); }); $router->group(['prefix' => 'exhibition'], function () use ($router) { From cf7ecc12bf4c767b70206f22fcdefb01817773c6 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Mon, 8 Mar 2021 00:45:50 +0900 Subject: [PATCH 069/132] feat: return term object --- app/Http/Resources/GuestResource.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/Http/Resources/GuestResource.php b/app/Http/Resources/GuestResource.php index 393c0406..b22a397e 100644 --- a/app/Http/Resources/GuestResource.php +++ b/app/Http/Resources/GuestResource.php @@ -15,10 +15,8 @@ class GuestResource extends Resource { public function toArray($request) { return [ 'id' => $this->id, - 'color_id' => $this->term->color_id, - 'term_id' => $this->term->id, + 'term' => $this->term, 'entered_at' => $this->entered_at, - 'exit_scheduled_time' => $this->term->exit_scheduled_time, 'exited_at' => $this->exited_at, 'exh_id' =>$this->exh_id, ]; From f097e8a5c48e9cee8b5e907e6f60c17432472cb5 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Mon, 8 Mar 2021 00:51:39 +0900 Subject: [PATCH 070/132] fix: return prefix in term info --- app/Http/Controllers/TermController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/TermController.php b/app/Http/Controllers/TermController.php index d6c5d47a..52479ea0 100644 --- a/app/Http/Controllers/TermController.php +++ b/app/Http/Controllers/TermController.php @@ -12,7 +12,7 @@ public function index() { $result[$term->id] = [ "enter_scheduled_time" => $term->enter_scheduled_time, "exit_scheduled_time" => $term->exit_scheduled_time, - "color_id" => $term->color_id + "prefix" => config('onsite.colors')[$term->color_id]['prefix'] ]; } From 0ef0ab68eb5f9e8a4f525f8010e8fb850c316195 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Mon, 8 Mar 2021 00:57:04 +0900 Subject: [PATCH 071/132] fix: rename violet color to purple --- config/onsite.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/onsite.php b/config/onsite.php index 8c793c46..2b7c1331 100644 --- a/config/onsite.php +++ b/config/onsite.php @@ -20,8 +20,8 @@ 'yellow' => [ 'prefix' => 'GY' ], - 'violet' => [ - 'prefix' => 'GV' + 'purple' => [ + 'prefix' => 'GP' ], 'orange' => [ 'prefix' => 'GO' From 2e77fc2528f2132263583f40497d81f4b171084f Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Mon, 8 Mar 2021 17:55:16 +0900 Subject: [PATCH 072/132] fix: rename color_id to guest_type --- app/Http/Controllers/GuestController.php | 2 +- app/Http/Controllers/TermController.php | 2 +- app/Models/Term.php | 2 +- config/onsite.php | 26 +++++++-------- ..._color_id_to_guest_type_on_terms_table.php | 32 +++++++++++++++++++ 5 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 database/migrations/2021_03_08_081853_rename_color_id_to_guest_type_on_terms_table.php diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index c800d0d7..8ae82d87 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -51,7 +51,7 @@ public function enter(Request $request) { $term = $reservation->term; - if (strpos($request->guest_id, config('onsite.colors')[$term->color_id]['prefix']) !== 0 + if (strpos($request->guest_id, config('onsite.guest_types')[$term->guest_type]['prefix']) !== 0 ) { throw new HttpExceptionWithErrorCode(400, 'WRONG_WRISTBAND_COLOR'); } diff --git a/app/Http/Controllers/TermController.php b/app/Http/Controllers/TermController.php index 52479ea0..1fd223c8 100644 --- a/app/Http/Controllers/TermController.php +++ b/app/Http/Controllers/TermController.php @@ -12,7 +12,7 @@ public function index() { $result[$term->id] = [ "enter_scheduled_time" => $term->enter_scheduled_time, "exit_scheduled_time" => $term->exit_scheduled_time, - "prefix" => config('onsite.colors')[$term->color_id]['prefix'] + "prefix" => config('onsite.guest_types')[$term->guest_type]['prefix'] ]; } diff --git a/app/Models/Term.php b/app/Models/Term.php index ca944a59..9e2e7a85 100644 --- a/app/Models/Term.php +++ b/app/Models/Term.php @@ -12,7 +12,7 @@ class Term extends Model { * @var array */ protected $fillable = [ - 'id', 'enter_scheduled_time', 'exit_scheduled_time', 'color_id', + 'id', 'enter_scheduled_time', 'exit_scheduled_time', 'guest_type', ]; /** diff --git a/config/onsite.php b/config/onsite.php index 2b7c1331..c8186ea6 100644 --- a/config/onsite.php +++ b/config/onsite.php @@ -3,45 +3,45 @@ /* |-------------------------------------------------------------------------- - | Color List + | GuestType List |-------------------------------------------------------------------------- | | Used for GuestController | This restrict the WristBand Prefix */ - 'colors' => [ - 'blue' => [ + 'guest_types' => [ + 'GuestBlue' => [ 'prefix' => 'GB' ], - 'red' => [ + 'GuestRed' => [ 'prefix' => 'GR' ], - 'yellow' => [ + 'GuestYellow' => [ 'prefix' => 'GY' ], - 'purple' => [ + 'GuestPurple' => [ 'prefix' => 'GP' ], - 'orange' => [ + 'GuestOrange' => [ 'prefix' => 'GO' ], - 'green' => [ + 'GuestGreen' => [ 'prefix' => 'GG' ], - 'white' => [ + 'GuestWhite' => [ 'prefix' => 'GW' ], - 'gray' => [ + 'GuestGray' => [ 'prefix' => 'SG' ], - 'test_blue' => [ + 'TestBlue' => [ 'prefix' => 'TB' ], - 'test_red' => [ + 'TestRed' => [ 'prefix' => 'TR' ], - 'test_yellow' => [ + 'TestYellow' => [ 'prefix' => 'TY' ] ] diff --git a/database/migrations/2021_03_08_081853_rename_color_id_to_guest_type_on_terms_table.php b/database/migrations/2021_03_08_081853_rename_color_id_to_guest_type_on_terms_table.php new file mode 100644 index 00000000..93d8817f --- /dev/null +++ b/database/migrations/2021_03_08_081853_rename_color_id_to_guest_type_on_terms_table.php @@ -0,0 +1,32 @@ +renameColumn('color_id', 'guest_type'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('terms', function (Blueprint $table) { + $table->renameColumn('guest_type', 'color_id'); + }); + } +} From 2a847d394e73c11d3a2e0a56e50dfbfb719144a0 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Mon, 8 Mar 2021 21:49:47 +0900 Subject: [PATCH 073/132] test: create onsite factories --- database/factories/ModelFactory.php | 54 +++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 6ee853c9..f7eb059b 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -96,3 +96,57 @@ 'user_id'=>$faker->userName() ]; }); + +$factory->define(App\Models\Term::class, function (Faker\Generator $faker) { + return [ + 'id'=>$faker->userName, + 'enter_scheduled_time'=>$faker->dateTime, + 'exit_scheduled_time'=>($faker->dateTime+$faker->dateTime), + 'guest_type'=>key(array_rand(config('onsite.guest_types'))) + ]; +}); + +$factory->define(App\Models\ExhibitionRoom::class, function (Faker\Generator $faker) { + $capacity = $faker->numberBetween(1); + return [ + 'id'=>$faker->userName, + 'room_id'=>$faker->userName, + 'capacity'=>$capacity, + 'guest_count'=>$faker->numberBetween(0,$capacity-1), + 'updated_at'=>$faker->dateTime, + ]; +}); + +$factory->define(App\Models\Guest::class, function (Faker\Generator $faker) { + return [ + 'id'=>$faker->userName, + 'entered_at'=>$faker->dateTime, + 'exited_at'=>$faker->dateTime, + 'exh_id'=>$faker->userName, + 'term_id'=>$faker->userName, + 'reservation_id'=>$faker->userName, + ]; +}); + +$factory->define(App\Models\Reservation::class, function (Faker\Generator $faker) { + return [ + 'id'=>$faker->userName, + 'people_count'=>$faker->numberBetween(1), + 'name'=>$faker->name, + 'term_id'=>$faker->userName, + 'email'=>$faker->email, + 'address'=>$faker->address, + 'cellphone'=>$faker->phoneNumber, + 'guest_id'=>$faker->userName, + ]; +}); + +$factory->define(App\Models\ActivityLog::class, function (Faker\Generator $faker) { + return [ + 'id'=>$faker->userName, + 'timestamp'=>$faker->dateTime, + 'exh_id'=>$faker->userName, + 'log_type'=>array_rand(['enter','exit']), + 'guest_id'=>$faker->userName, + ]; +}); From d5745488ec3c2a752b8785778ff170a0fd3c4ad9 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Mon, 8 Mar 2021 22:54:07 +0900 Subject: [PATCH 074/132] test: fix model factory --- database/factories/ModelFactory.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index f7eb059b..cdf537ea 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -100,9 +100,9 @@ $factory->define(App\Models\Term::class, function (Faker\Generator $faker) { return [ 'id'=>$faker->userName, - 'enter_scheduled_time'=>$faker->dateTime, - 'exit_scheduled_time'=>($faker->dateTime+$faker->dateTime), - 'guest_type'=>key(array_rand(config('onsite.guest_types'))) + 'enter_scheduled_time'=>$faker->dateTimeBetween('-1year', '-1hour'), + 'exit_scheduled_time'=>$faker->dateTimeBetween('+1hour', '+1year'), + 'guest_type'=>array_rand(config('onsite.guest_types')) ]; }); @@ -121,8 +121,8 @@ return [ 'id'=>$faker->userName, 'entered_at'=>$faker->dateTime, - 'exited_at'=>$faker->dateTime, - 'exh_id'=>$faker->userName, + 'exited_at'=>null, + 'exh_id'=>null, 'term_id'=>$faker->userName, 'reservation_id'=>$faker->userName, ]; @@ -137,7 +137,7 @@ 'email'=>$faker->email, 'address'=>$faker->address, 'cellphone'=>$faker->phoneNumber, - 'guest_id'=>$faker->userName, + 'guest_id'=>null ]; }); From de1d62e97128746757dbdcbba631d72aa98f39e2 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Mon, 8 Mar 2021 22:54:26 +0900 Subject: [PATCH 075/132] test: create guest entrance enter --- tests/onsite/GeneralEntranceTest.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/onsite/GeneralEntranceTest.php diff --git a/tests/onsite/GeneralEntranceTest.php b/tests/onsite/GeneralEntranceTest.php new file mode 100644 index 00000000..5aa2a162 --- /dev/null +++ b/tests/onsite/GeneralEntranceTest.php @@ -0,0 +1,23 @@ +create(); + $term = factory(Term::class)->create(); + $reservation = factory(Reservation::class)->create([ + 'term_id' => $term->id + ]); + $guest_id = config('onsite.guest_types')[$term->guest_type]['prefix']."-".Str::random(5); + $this->actingAs($user)->post( + '/onsite/general/enter', + ['guest_id' => $guest_id, 'reservation_id' => $reservation->id] + ); + $this->assertResponseOk(); + } +} From e459ac7c3b23127c9be9b10fa7ac0f8e206754d7 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 9 Mar 2021 23:10:18 +0900 Subject: [PATCH 076/132] test: move "generalEntranceTest" to "general/EntranceTest" --- .../{GeneralEntranceTest.php => General/EntranceTest.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename tests/onsite/{GeneralEntranceTest.php => General/EntranceTest.php} (93%) diff --git a/tests/onsite/GeneralEntranceTest.php b/tests/onsite/General/EntranceTest.php similarity index 93% rename from tests/onsite/GeneralEntranceTest.php rename to tests/onsite/General/EntranceTest.php index 5aa2a162..76da4368 100644 --- a/tests/onsite/GeneralEntranceTest.php +++ b/tests/onsite/General/EntranceTest.php @@ -6,7 +6,7 @@ use App\Models\User; use Illuminate\Support\Str; -class GeneralEntranceTest extends TestCase { +class EntranceTest extends TestCase { public function testEnter() { $user = factory(User::class, 'general')->create(); $term = factory(Term::class)->create(); From c96b8cc6640913e7a95660eb4fa6c99e8e88cdd3 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 9 Mar 2021 23:11:08 +0900 Subject: [PATCH 077/132] test: create InvalidGuestCodeCheck --- tests/onsite/General/EntranceTest.php | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/onsite/General/EntranceTest.php b/tests/onsite/General/EntranceTest.php index 76da4368..d12db42f 100644 --- a/tests/onsite/General/EntranceTest.php +++ b/tests/onsite/General/EntranceTest.php @@ -20,4 +20,34 @@ public function testEnter() { ); $this->assertResponseOk(); } + + public function testInvalidGuestCode() { + $invalid_codes = []; + $count = 5; + + $user = factory(User::class, 'general')->create(); + $term = factory(Term::class)->create(); + $reservation = factory(Reservation::class)->create([ + 'term_id' => $term->id + ]); + + for ($i = 0; $i < $count; ++$i) { + do { + $prefix = rand(1, 10); + $id = rand(1, 10); + } while ($prefix == 2 && $id == 5); + $invalid_codes[] = Str::random($prefix).'-'.Str::random($id); + } + + foreach ($invalid_codes as $invalid_code) { + $this->actingAs($user)->post( + '/onsite/general/enter', + ['guest_id' => $invalid_code, 'reservation_id' => $reservation->id] + ); + $this->assertResponseStatus(400); + $this->receiveJson(); + $code = json_decode($this->response->getContent())->error_code; + $this->assertEquals($code, 'INVALID_WRISTBAND_CODE'); + } + } } From d932bbde4d79b1c403fe0be6b35de87776b6dd45 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Wed, 10 Mar 2021 22:46:19 +0900 Subject: [PATCH 078/132] fix: use term instead of term_id --- app/Http/Resources/ReservationResource.php | 2 +- app/Http/Resources/ReservationWithPrivateResource.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Resources/ReservationResource.php b/app/Http/Resources/ReservationResource.php index 2a539cf2..cbed0b70 100644 --- a/app/Http/Resources/ReservationResource.php +++ b/app/Http/Resources/ReservationResource.php @@ -16,7 +16,7 @@ public function toArray($request) { return [ 'id' => $this->id, 'email' => $this->email, - 'term_id' => $this->term_id, + 'term' => $this->term, 'people_count' => $this->people_count ]; } diff --git a/app/Http/Resources/ReservationWithPrivateResource.php b/app/Http/Resources/ReservationWithPrivateResource.php index 7d669f62..fb4de563 100644 --- a/app/Http/Resources/ReservationWithPrivateResource.php +++ b/app/Http/Resources/ReservationWithPrivateResource.php @@ -16,7 +16,7 @@ public function toArray($request) { return [ 'id' => $this->id, 'email' => $this->email, - 'term_id' => $this->term_id, + 'term' => $this->term, 'people_count' => $this->people_count, 'name' => $this->name, 'address' => $this->address, From d14b2f9032474f9bc9edb0f44a4a1d38fa52e7d9 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Thu, 11 Mar 2021 11:05:36 +0900 Subject: [PATCH 079/132] fix: return term in reservation/check --- app/Http/Controllers/ReservationController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/ReservationController.php b/app/Http/Controllers/ReservationController.php index d970b7e7..02416ed0 100644 --- a/app/Http/Controllers/ReservationController.php +++ b/app/Http/Controllers/ReservationController.php @@ -69,7 +69,7 @@ public function check($id) { $res = [ 'valid' => $valid, 'status_code' => $status_code, - 'term_id' => $reservation->term_id + 'term' => $reservation->term ]; return response()->json($res); From 967120fb682f8fb1e9aed73626f89036dca3dcff Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 13 Mar 2021 16:19:49 +0900 Subject: [PATCH 080/132] test: fix: flip args of assertEquals --- tests/onsite/General/EntranceTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/onsite/General/EntranceTest.php b/tests/onsite/General/EntranceTest.php index d12db42f..f998f4b8 100644 --- a/tests/onsite/General/EntranceTest.php +++ b/tests/onsite/General/EntranceTest.php @@ -47,7 +47,7 @@ public function testInvalidGuestCode() { $this->assertResponseStatus(400); $this->receiveJson(); $code = json_decode($this->response->getContent())->error_code; - $this->assertEquals($code, 'INVALID_WRISTBAND_CODE'); + $this->assertEquals('INVALID_WRISTBAND_CODE', $code); } } } From 9a0b80f469af8439d3581913a9fd3227c756d7e3 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 13 Mar 2021 16:20:22 +0900 Subject: [PATCH 081/132] test: generl/enter/alreadyUsedGuestCode --- tests/onsite/General/EntranceTest.php | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/onsite/General/EntranceTest.php b/tests/onsite/General/EntranceTest.php index f998f4b8..84df0571 100644 --- a/tests/onsite/General/EntranceTest.php +++ b/tests/onsite/General/EntranceTest.php @@ -50,4 +50,41 @@ public function testInvalidGuestCode() { $this->assertEquals('INVALID_WRISTBAND_CODE', $code); } } + + public function testAlreadyUsedGuestCode() { + $count = 5; + + $user = factory(User::class, 'general')->create(); + $term = factory(Term::class)->create(); + $used_id = []; + for ($i = 0; $i < $count; ++$i) { + $reservation_1 = factory(Reservation::class)->create([ + 'term_id' => $term->id + ]); + $reservation_2 = factory(Reservation::class)->create([ + 'term_id' => $term->id + ]); + do { + $guest_id = config('onsite.guest_types')[$term->guest_type]['prefix']."-".Str::random(5); + } while (in_array($guest_id, $used_id)); + $used_id[] = $guest_id; + + $this->actingAs($user)->post( + '/onsite/general/enter', + ['guest_id' => $guest_id, 'reservation_id' => $reservation_1->id] + ); + + $this->assertResponseOk(); + + $this->actingAs($user)->post( + '/onsite/general/enter', + ['guest_id' => $guest_id, 'reservation_id' => $reservation_2->id] + ); + + $this->assertResponseStatus(400); + $this->receiveJson(); + $code = json_decode($this->response->getContent())->error_code; + $this->assertEquals('ALREADY_USED_WRISTBAND', $code); + } + } } From 68ae7b9a09a340275db8cda5daec6006da3dd297 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 13 Mar 2021 16:20:55 +0900 Subject: [PATCH 082/132] test: generl/enter/notFoundReservation --- tests/onsite/General/EntranceTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/onsite/General/EntranceTest.php b/tests/onsite/General/EntranceTest.php index 84df0571..4f35cfd8 100644 --- a/tests/onsite/General/EntranceTest.php +++ b/tests/onsite/General/EntranceTest.php @@ -87,4 +87,21 @@ public function testAlreadyUsedGuestCode() { $this->assertEquals('ALREADY_USED_WRISTBAND', $code); } } + + public function testReservationNotFound() { + $user = factory(User::class, 'general')->create(); + $term = factory(Term::class)->create(); + $guest_id = config('onsite.guest_types')[$term->guest_type]['prefix']."-".Str::random(5); + $this->actingAs($user)->post( + '/onsite/general/enter', + ['guest_id' => $guest_id, 'reservation_id' => 'R-'.Str::random(7)] + ); + + $this->assertResponseStatus(400); + $this->receiveJson(); + $code = json_decode($this->response->getContent())->error_code; + $this->assertEquals('RESERVATION_NOT_FOUND', $code); + } + + // INVALID_RESERVATION_INFO: NO TEST } From 6900aecbd6d94437fd24665fb39f14ac23c74e55 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 13 Mar 2021 16:21:26 +0900 Subject: [PATCH 083/132] test: generl/enter/AlreadyEnteredReservation --- tests/onsite/General/EntranceTest.php | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/onsite/General/EntranceTest.php b/tests/onsite/General/EntranceTest.php index 4f35cfd8..6a41cbcd 100644 --- a/tests/onsite/General/EntranceTest.php +++ b/tests/onsite/General/EntranceTest.php @@ -104,4 +104,44 @@ public function testReservationNotFound() { } // INVALID_RESERVATION_INFO: NO TEST + + public function testAlreadyEnteredReservation() { + $count = 5; + + $user = factory(User::class, 'general')->create(); + $term = factory(Term::class)->create(); + $used_id = []; + for ($i = 0; $i < $count; ++$i) { + $reservation = factory(Reservation::class)->create([ + 'term_id' => $term->id + ]); + + do { + $guest_id_1 = config('onsite.guest_types')[$term->guest_type]['prefix']."-".Str::random(5); + } while (in_array($guest_id_1, $used_id)); + $used_id[] = $guest_id_1; + + do { + $guest_id_2 = config('onsite.guest_types')[$term->guest_type]['prefix']."-".Str::random(5); + } while (in_array($guest_id_2, $used_id)); + $used_id[] = $guest_id_2; + + $this->actingAs($user)->post( + '/onsite/general/enter', + ['guest_id' => $guest_id_1, 'reservation_id' => $reservation->id] + ); + + $this->assertResponseOk(); + + $this->actingAs($user)->post( + '/onsite/general/enter', + ['guest_id' => $guest_id_1, 'reservation_id' => $reservation->id] + ); + + $this->assertResponseStatus(400); + $this->receiveJson(); + $code = json_decode($this->response->getContent())->error_code; + $this->assertEquals('ALREADY_ENTERED_RESERVATION', $code); + } + } } From 1cafa1528c64a9039b95b7deee1c4c7b12006b7e Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 13 Mar 2021 16:22:05 +0900 Subject: [PATCH 084/132] test: generl/enter/OutOfReservationTime --- tests/onsite/General/EntranceTest.php | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/onsite/General/EntranceTest.php b/tests/onsite/General/EntranceTest.php index 6a41cbcd..a92e49df 100644 --- a/tests/onsite/General/EntranceTest.php +++ b/tests/onsite/General/EntranceTest.php @@ -4,6 +4,7 @@ use App\Models\Reservation; use App\Models\Term; use App\Models\User; +use Faker\Provider\DateTime; use Illuminate\Support\Str; class EntranceTest extends TestCase { @@ -144,4 +145,40 @@ public function testAlreadyEnteredReservation() { $this->assertEquals('ALREADY_ENTERED_RESERVATION', $code); } } + + public function testOutOfReservationTime() { + $user = factory(User::class, 'general')->create(); + $term = factory(Term::class)->create([ + 'enter_scheduled_time'=>DateTime::dateTimeBetween('-1 year', '-1 day'), + 'exit_scheduled_time'=>DateTime::dateTimeBetween('-1 year', '-1 day') + ]); + $reservation = factory(Reservation::class)->create([ + 'term_id' => $term->id + ]); + $guest_id = config('onsite.guest_types')[$term->guest_type]['prefix']."-".Str::random(5); + $this->actingAs($user)->post( + '/onsite/general/enter', + ['guest_id' => $guest_id, 'reservation_id' => $reservation->id] + ); + + $this->assertResponseStatus(400); + $this->receiveJson(); + $code = json_decode($this->response->getContent())->error_code; + $this->assertEquals('OUT_OF_RESERVATION_TIME', $code); + + $term = factory(Term::class)->create([ + 'enter_scheduled_time'=>DateTime::dateTimeBetween('+1 day', '+1 year'), + 'exit_scheduled_time'=>DateTime::dateTimeBetween('+1 day', '+1 year') + ]); + + $this->actingAs($user)->post( + '/onsite/general/enter', + ['guest_id' => $guest_id, 'reservation_id' => $reservation->id] + ); + + $this->assertResponseStatus(400); + $this->receiveJson(); + $code = json_decode($this->response->getContent())->error_code; + $this->assertEquals('OUT_OF_RESERVATION_TIME', $code); + } } From c8f9baf3f4bba8939dbd41c41b65b1db647b2189 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 13 Mar 2021 16:22:18 +0900 Subject: [PATCH 085/132] test: generl/enter/WrongWristBandColor --- tests/onsite/General/EntranceTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/onsite/General/EntranceTest.php b/tests/onsite/General/EntranceTest.php index a92e49df..1b7734e0 100644 --- a/tests/onsite/General/EntranceTest.php +++ b/tests/onsite/General/EntranceTest.php @@ -181,4 +181,22 @@ public function testOutOfReservationTime() { $code = json_decode($this->response->getContent())->error_code; $this->assertEquals('OUT_OF_RESERVATION_TIME', $code); } + + public function testWrongWristbandColor() { + $user = factory(User::class, 'general')->create(); + $term = factory(Term::class)->create(); + $reservation = factory(Reservation::class)->create([ + 'term_id' => $term->id + ]); + $guest_id = "XX" . "-" . Str::random(5); // 存在しないリストバンド prefix + $this->actingAs($user)->post( + '/onsite/general/enter', + ['guest_id' => $guest_id, 'reservation_id' => $reservation->id] + ); + + $this->assertResponseStatus(400); + $this->receiveJson(); + $code = json_decode($this->response->getContent())->error_code; + $this->assertEquals('WRONG_WRISTBAND_COLOR', $code); + } } From 10ff4ab37516debe1ff5a91c6a070a1a25c86d9f Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 13 Mar 2021 17:31:11 +0900 Subject: [PATCH 086/132] feat: EXHIBITION_NOT_FOUND --- app/Http/Controllers/ExhibitionRoomController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Http/Controllers/ExhibitionRoomController.php b/app/Http/Controllers/ExhibitionRoomController.php index 15f8e865..358ecbde 100644 --- a/app/Http/Controllers/ExhibitionRoomController.php +++ b/app/Http/Controllers/ExhibitionRoomController.php @@ -47,6 +47,7 @@ public function enter(Request $request) { $exh = ExhibitionRoom::find($user_id); $current = Carbon::now(); + if (!$exh) throw new HttpExceptionWithErrorCode(400, 'EXHIBITION_NOT_FOUND'); if (!$guest) throw new HttpExceptionWithErrorCode(400, 'GUEST_NOT_FOUND'); if ($guest->exh_id === $user_id) @@ -82,6 +83,7 @@ public function exit(Request $request) { $guest = Guest::find($request->guest_id); $exh = ExhibitionRoom::find($user_id); + if (!$exh) throw new HttpExceptionWithErrorCode(400, 'EXHIBITION_NOT_FOUND'); if (!$guest) throw new HttpExceptionWithErrorCode(400, 'GUEST_NOT_FOUND'); if ($guest->exited_at !== null) From 090544496a6539e284e701d220509eb5d3acb6b4 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 13 Mar 2021 17:35:49 +0900 Subject: [PATCH 087/132] fix: return status code instead of 404/409 --- app/Http/Controllers/GuestController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index 8ae82d87..2e24d250 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -78,11 +78,11 @@ public function exit(Request $request) { $guest = Guest::find($request->guest_id); if (!$guest) { - abort(404); + throw new HttpExceptionWithErrorCode(400, 'GUEST_NOT_FOUND'); } if ($guest->exited_at !== null) { - abort(409); + throw new HttpExceptionWithErrorCode(400, 'GUEST_ALREADY_EXITED'); } $guest->update(['exited_at' => Carbon::now()]); From 306a7ef9799ab7088e317b752f7706e2057be484 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 13 Mar 2021 17:47:10 +0900 Subject: [PATCH 088/132] style: auto fix by phpcbf --- .../2020_08_25_021722_create_reservations_table.php | 10 ++++------ .../2020_08_25_023544_create_guests_table.php | 10 ++++------ .../2020_08_25_024543_create_activity_logs_table.php | 10 ++++------ .../2020_08_25_111818_create_terms_table.php | 10 ++++------ ...2021_02_18_005707_create_exhibition_rooms_table.php | 10 ++++------ ...53_rename_color_id_to_guest_type_on_terms_table.php | 10 ++++------ 6 files changed, 24 insertions(+), 36 deletions(-) diff --git a/database/migrations/2020_08_25_021722_create_reservations_table.php b/database/migrations/2020_08_25_021722_create_reservations_table.php index c0e8e262..0ddaeb0c 100644 --- a/database/migrations/2020_08_25_021722_create_reservations_table.php +++ b/database/migrations/2020_08_25_021722_create_reservations_table.php @@ -4,15 +4,14 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateReservationsTable extends Migration -{ +class CreateReservationsTable extends Migration { + /** * Run the migrations. * * @return void */ - public function up() - { + public function up() { Schema::create('reservations', function (Blueprint $table) { $table->string('id'); $table->primary('id'); @@ -31,8 +30,7 @@ public function up() * * @return void */ - public function down() - { + public function down() { Schema::dropIfExists('reservations'); } } diff --git a/database/migrations/2020_08_25_023544_create_guests_table.php b/database/migrations/2020_08_25_023544_create_guests_table.php index 4abff4a6..851ff06a 100644 --- a/database/migrations/2020_08_25_023544_create_guests_table.php +++ b/database/migrations/2020_08_25_023544_create_guests_table.php @@ -4,15 +4,14 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateGuestsTable extends Migration -{ +class CreateGuestsTable extends Migration { + /** * Run the migrations. * * @return void */ - public function up() - { + public function up() { Schema::create('guests', function (Blueprint $table) { $table->string('id'); $table->primary('id'); @@ -29,8 +28,7 @@ public function up() * * @return void */ - public function down() - { + public function down() { Schema::dropIfExists('guests'); } } diff --git a/database/migrations/2020_08_25_024543_create_activity_logs_table.php b/database/migrations/2020_08_25_024543_create_activity_logs_table.php index e9f84068..5b63e8c6 100644 --- a/database/migrations/2020_08_25_024543_create_activity_logs_table.php +++ b/database/migrations/2020_08_25_024543_create_activity_logs_table.php @@ -4,15 +4,14 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateActivityLogsTable extends Migration -{ +class CreateActivityLogsTable extends Migration { + /** * Run the migrations. * * @return void */ - public function up() - { + public function up() { Schema::create('activity_logs', function (Blueprint $table) { $table->bigIncrements('id'); $table->timestamp('timestamp')->useCurrent(); @@ -27,8 +26,7 @@ public function up() * * @return void */ - public function down() - { + public function down() { Schema::dropIfExists('activity_logs'); } } diff --git a/database/migrations/2020_08_25_111818_create_terms_table.php b/database/migrations/2020_08_25_111818_create_terms_table.php index 6e65d452..feaaba53 100644 --- a/database/migrations/2020_08_25_111818_create_terms_table.php +++ b/database/migrations/2020_08_25_111818_create_terms_table.php @@ -4,15 +4,14 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateTermsTable extends Migration -{ +class CreateTermsTable extends Migration { + /** * Run the migrations. * * @return void */ - public function up() - { + public function up() { Schema::create('terms', function (Blueprint $table) { $table->string('id'); $table->primary('id'); @@ -27,8 +26,7 @@ public function up() * * @return void */ - public function down() - { + public function down() { Schema::dropIfExists('terms'); } } diff --git a/database/migrations/2021_02_18_005707_create_exhibition_rooms_table.php b/database/migrations/2021_02_18_005707_create_exhibition_rooms_table.php index 8ad13b20..9c456ad8 100644 --- a/database/migrations/2021_02_18_005707_create_exhibition_rooms_table.php +++ b/database/migrations/2021_02_18_005707_create_exhibition_rooms_table.php @@ -4,15 +4,14 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class CreateExhibitionRoomsTable extends Migration -{ +class CreateExhibitionRoomsTable extends Migration { + /** * Run the migrations. * * @return void */ - public function up() - { + public function up() { Schema::create('exh_rooms', function (Blueprint $table) { $table->string('id'); $table->primary('id'); @@ -28,8 +27,7 @@ public function up() * * @return void */ - public function down() - { + public function down() { Schema::dropIfExists('exh_rooms'); } } diff --git a/database/migrations/2021_03_08_081853_rename_color_id_to_guest_type_on_terms_table.php b/database/migrations/2021_03_08_081853_rename_color_id_to_guest_type_on_terms_table.php index 93d8817f..8b1d41c8 100644 --- a/database/migrations/2021_03_08_081853_rename_color_id_to_guest_type_on_terms_table.php +++ b/database/migrations/2021_03_08_081853_rename_color_id_to_guest_type_on_terms_table.php @@ -4,15 +4,14 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class RenameColorIdToGuestTypeOnTermsTable extends Migration -{ +class RenameColorIdToGuestTypeOnTermsTable extends Migration { + /** * Run the migrations. * * @return void */ - public function up() - { + public function up() { Schema::table('terms', function (Blueprint $table) { $table->renameColumn('color_id', 'guest_type'); }); @@ -23,8 +22,7 @@ public function up() * * @return void */ - public function down() - { + public function down() { Schema::table('terms', function (Blueprint $table) { $table->renameColumn('guest_type', 'color_id'); }); From f2513d0103d070b7738505fa45bbe779a9d016cd Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 13 Mar 2021 17:48:13 +0900 Subject: [PATCH 089/132] test: test when entertime is over --- tests/onsite/General/EntranceTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/onsite/General/EntranceTest.php b/tests/onsite/General/EntranceTest.php index 1b7734e0..6c2e2cc6 100644 --- a/tests/onsite/General/EntranceTest.php +++ b/tests/onsite/General/EntranceTest.php @@ -171,6 +171,14 @@ public function testOutOfReservationTime() { 'exit_scheduled_time'=>DateTime::dateTimeBetween('+1 day', '+1 year') ]); + $this->actingAs($user)->post( + '/onsite/general/enter', + ['guest_id' => $guest_id, 'reservation_id' => $reservation->id] + ); + $reservation = factory(Reservation::class)->create([ + 'term_id' => $term->id + ]); + $guest_id = config('onsite.guest_types')[$term->guest_type]['prefix']."-".Str::random(5); $this->actingAs($user)->post( '/onsite/general/enter', ['guest_id' => $guest_id, 'reservation_id' => $reservation->id] From 8edbdadf2821ea486a8026ef19ea82f3971094fe Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 13 Mar 2021 22:04:41 +0900 Subject: [PATCH 090/132] test: general/exit --- tests/onsite/General/EntranceTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/onsite/General/EntranceTest.php b/tests/onsite/General/EntranceTest.php index 6c2e2cc6..05f335dc 100644 --- a/tests/onsite/General/EntranceTest.php +++ b/tests/onsite/General/EntranceTest.php @@ -1,6 +1,7 @@ response->getContent())->error_code; $this->assertEquals('WRONG_WRISTBAND_COLOR', $code); } + + public function testExit() { + $user = factory(User::class, 'general')->create(); + $term = factory(Term::class)->create(); + $reservation = factory(Reservation::class)->create([ + 'term_id' => $term->id + ]); + $guest = factory(Guest::class)->create([ + 'reservation_id' => $reservation->id + ]); + + $this->actingAs($user)->post( + '/onsite/general/exit', + ['guest_id' => $guest->id] + ); + $this->assertResponseOk(); + } } From bfabdb00ad918555eeffe9ac1e77654b6da245b2 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 13 Mar 2021 22:04:53 +0900 Subject: [PATCH 091/132] test: general/exit/GuestNotFound --- tests/onsite/General/EntranceTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/onsite/General/EntranceTest.php b/tests/onsite/General/EntranceTest.php index 05f335dc..7d6deb97 100644 --- a/tests/onsite/General/EntranceTest.php +++ b/tests/onsite/General/EntranceTest.php @@ -225,4 +225,20 @@ public function testExit() { ); $this->assertResponseOk(); } + + public function testExitGuestNotFound() { + $user = factory(User::class, 'general')->create(); + $term = factory(Term::class)->create(); + $guest_id = config('onsite.guest_types')[$term->guest_type]['prefix']."-".Str::random(5); + + + $this->actingAs($user)->post( + '/onsite/general/exit', + ['guest_id' => $guest_id] + ); + $this->assertResponseStatus(400); + $this->receiveJson(); + $code = json_decode($this->response->getContent())->error_code; + $this->assertEquals('GUEST_NOT_FOUND', $code); + } } From cd61c8cb7f9b1804adcd3d33f224d5f8488eeda1 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 13 Mar 2021 22:06:40 +0900 Subject: [PATCH 092/132] test: general/exit/GuestAlreadyExited --- tests/onsite/General/EntranceTest.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/onsite/General/EntranceTest.php b/tests/onsite/General/EntranceTest.php index 7d6deb97..a8ab8a05 100644 --- a/tests/onsite/General/EntranceTest.php +++ b/tests/onsite/General/EntranceTest.php @@ -241,4 +241,28 @@ public function testExitGuestNotFound() { $code = json_decode($this->response->getContent())->error_code; $this->assertEquals('GUEST_NOT_FOUND', $code); } + + public function testAlreadyExited() { + $user = factory(User::class, 'general')->create(); + $term = factory(Term::class)->create(); + $reservation = factory(Reservation::class)->create([ + 'term_id' => $term->id + ]); + $guest = factory(Guest::class)->create([ + 'reservation_id' => $reservation->id + ]); + + $this->actingAs($user)->post( + '/onsite/general/exit', + ['guest_id' => $guest->id] + ); + $this->actingAs($user)->post( + '/onsite/general/exit', + ['guest_id' => $guest->id] + ); + $this->assertResponseStatus(400); + $this->receiveJson(); + $code = json_decode($this->response->getContent())->error_code; + $this->assertEquals('GUEST_ALREADY_EXITED', $code); + } } From 8de13a9724653465d7c8c9f85d35b01c58f3e8d7 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 16 Mar 2021 22:11:04 +0900 Subject: [PATCH 093/132] style: fix by phpcs --- tests/onsite/General/EntranceTest.php | 29 ++++++++++++++------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/tests/onsite/General/EntranceTest.php b/tests/onsite/General/EntranceTest.php index a8ab8a05..9e0c851b 100644 --- a/tests/onsite/General/EntranceTest.php +++ b/tests/onsite/General/EntranceTest.php @@ -9,13 +9,14 @@ use Illuminate\Support\Str; class EntranceTest extends TestCase { + public function testEnter() { $user = factory(User::class, 'general')->create(); $term = factory(Term::class)->create(); $reservation = factory(Reservation::class)->create([ 'term_id' => $term->id ]); - $guest_id = config('onsite.guest_types')[$term->guest_type]['prefix']."-".Str::random(5); + $guest_id = config('onsite.guest_types')[$term->guest_type]['prefix'] . "-" . Str::random(5); $this->actingAs($user)->post( '/onsite/general/enter', ['guest_id' => $guest_id, 'reservation_id' => $reservation->id] @@ -38,7 +39,7 @@ public function testInvalidGuestCode() { $prefix = rand(1, 10); $id = rand(1, 10); } while ($prefix == 2 && $id == 5); - $invalid_codes[] = Str::random($prefix).'-'.Str::random($id); + $invalid_codes[] = Str::random($prefix) . '-' . Str::random($id); } foreach ($invalid_codes as $invalid_code) { @@ -67,7 +68,7 @@ public function testAlreadyUsedGuestCode() { 'term_id' => $term->id ]); do { - $guest_id = config('onsite.guest_types')[$term->guest_type]['prefix']."-".Str::random(5); + $guest_id = config('onsite.guest_types')[$term->guest_type]['prefix'] . "-" . Str::random(5); } while (in_array($guest_id, $used_id)); $used_id[] = $guest_id; @@ -93,10 +94,10 @@ public function testAlreadyUsedGuestCode() { public function testReservationNotFound() { $user = factory(User::class, 'general')->create(); $term = factory(Term::class)->create(); - $guest_id = config('onsite.guest_types')[$term->guest_type]['prefix']."-".Str::random(5); + $guest_id = config('onsite.guest_types')[$term->guest_type]['prefix'] . "-" . Str::random(5); $this->actingAs($user)->post( '/onsite/general/enter', - ['guest_id' => $guest_id, 'reservation_id' => 'R-'.Str::random(7)] + ['guest_id' => $guest_id, 'reservation_id' => 'R-' . Str::random(7)] ); $this->assertResponseStatus(400); @@ -119,12 +120,12 @@ public function testAlreadyEnteredReservation() { ]); do { - $guest_id_1 = config('onsite.guest_types')[$term->guest_type]['prefix']."-".Str::random(5); + $guest_id_1 = config('onsite.guest_types')[$term->guest_type]['prefix'] . "-" . Str::random(5); } while (in_array($guest_id_1, $used_id)); $used_id[] = $guest_id_1; do { - $guest_id_2 = config('onsite.guest_types')[$term->guest_type]['prefix']."-".Str::random(5); + $guest_id_2 = config('onsite.guest_types')[$term->guest_type]['prefix'] . "-" . Str::random(5); } while (in_array($guest_id_2, $used_id)); $used_id[] = $guest_id_2; @@ -150,13 +151,13 @@ public function testAlreadyEnteredReservation() { public function testOutOfReservationTime() { $user = factory(User::class, 'general')->create(); $term = factory(Term::class)->create([ - 'enter_scheduled_time'=>DateTime::dateTimeBetween('-1 year', '-1 day'), - 'exit_scheduled_time'=>DateTime::dateTimeBetween('-1 year', '-1 day') + 'enter_scheduled_time' => DateTime::dateTimeBetween('-1 year', '-1 day'), + 'exit_scheduled_time' => DateTime::dateTimeBetween('-1 year', '-1 day') ]); $reservation = factory(Reservation::class)->create([ 'term_id' => $term->id ]); - $guest_id = config('onsite.guest_types')[$term->guest_type]['prefix']."-".Str::random(5); + $guest_id = config('onsite.guest_types')[$term->guest_type]['prefix'] . "-" . Str::random(5); $this->actingAs($user)->post( '/onsite/general/enter', ['guest_id' => $guest_id, 'reservation_id' => $reservation->id] @@ -168,8 +169,8 @@ public function testOutOfReservationTime() { $this->assertEquals('OUT_OF_RESERVATION_TIME', $code); $term = factory(Term::class)->create([ - 'enter_scheduled_time'=>DateTime::dateTimeBetween('+1 day', '+1 year'), - 'exit_scheduled_time'=>DateTime::dateTimeBetween('+1 day', '+1 year') + 'enter_scheduled_time' => DateTime::dateTimeBetween('+1 day', '+1 year'), + 'exit_scheduled_time' => DateTime::dateTimeBetween('+1 day', '+1 year') ]); $this->actingAs($user)->post( @@ -179,7 +180,7 @@ public function testOutOfReservationTime() { $reservation = factory(Reservation::class)->create([ 'term_id' => $term->id ]); - $guest_id = config('onsite.guest_types')[$term->guest_type]['prefix']."-".Str::random(5); + $guest_id = config('onsite.guest_types')[$term->guest_type]['prefix'] . "-" . Str::random(5); $this->actingAs($user)->post( '/onsite/general/enter', ['guest_id' => $guest_id, 'reservation_id' => $reservation->id] @@ -229,7 +230,7 @@ public function testExit() { public function testExitGuestNotFound() { $user = factory(User::class, 'general')->create(); $term = factory(Term::class)->create(); - $guest_id = config('onsite.guest_types')[$term->guest_type]['prefix']."-".Str::random(5); + $guest_id = config('onsite.guest_types')[$term->guest_type]['prefix'] . "-" . Str::random(5); $this->actingAs($user)->post( From 67b7513bc8826dc613fcd375b7aaece27ad773ae Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 16 Mar 2021 22:13:14 +0900 Subject: [PATCH 094/132] test: entrance forbidden --- tests/onsite/General/EntranceTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/onsite/General/EntranceTest.php b/tests/onsite/General/EntranceTest.php index 9e0c851b..8bbca3ce 100644 --- a/tests/onsite/General/EntranceTest.php +++ b/tests/onsite/General/EntranceTest.php @@ -266,4 +266,21 @@ public function testAlreadyExited() { $code = json_decode($this->response->getContent())->error_code; $this->assertEquals('GUEST_ALREADY_EXITED', $code); } + + public function testForbidden() { + $users[] = factory(User::class, 'exhibition')->create(); + $users[] = factory(User::class, 'admin')->create(); // ADMIN perm doesnt mean all perm + $users[] = factory(User::class)->create(); + + $paths = [ + '/onsite/general/exit', '/onsite/general/enter', + ]; + + foreach ($users as $user) { + foreach ($paths as $path) { + $this->actingAs($user)->post($path); + $this->assertResponseStatus(403); + } + } + } } From 167e6ead252e6eaed55f76950b96362d9ca42e7d Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 16 Mar 2021 22:13:37 +0900 Subject: [PATCH 095/132] test: entrance guest --- tests/onsite/General/EntranceTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/onsite/General/EntranceTest.php b/tests/onsite/General/EntranceTest.php index 8bbca3ce..c3b43dde 100644 --- a/tests/onsite/General/EntranceTest.php +++ b/tests/onsite/General/EntranceTest.php @@ -283,4 +283,15 @@ public function testForbidden() { } } } + + public function testGuest() { + $paths = [ + '/onsite/general/exit', '/onsite/general/enter', + ]; + + foreach ($paths as $path) { + $this->post($path); + $this->assertResponseStatus(401); + } + } } From 658417bc1e853289541806826e88af37bdbca1f5 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Tue, 16 Mar 2021 22:13:49 +0900 Subject: [PATCH 096/132] test: create GuestTest --- tests/onsite/General/GuestTest.php | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/onsite/General/GuestTest.php diff --git a/tests/onsite/General/GuestTest.php b/tests/onsite/General/GuestTest.php new file mode 100644 index 00000000..59b3df76 --- /dev/null +++ b/tests/onsite/General/GuestTest.php @@ -0,0 +1,6 @@ + Date: Tue, 16 Mar 2021 22:20:14 +0900 Subject: [PATCH 097/132] test: add path description --- tests/onsite/General/EntranceTest.php | 3 +++ tests/onsite/General/GuestTest.php | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/tests/onsite/General/EntranceTest.php b/tests/onsite/General/EntranceTest.php index c3b43dde..75911c71 100644 --- a/tests/onsite/General/EntranceTest.php +++ b/tests/onsite/General/EntranceTest.php @@ -8,6 +8,9 @@ use Faker\Provider\DateTime; use Illuminate\Support\Str; +/* + * general/enter:post, general/exit:post + */ class EntranceTest extends TestCase { public function testEnter() { diff --git a/tests/onsite/General/GuestTest.php b/tests/onsite/General/GuestTest.php index 59b3df76..003428cb 100644 --- a/tests/onsite/General/GuestTest.php +++ b/tests/onsite/General/GuestTest.php @@ -1,6 +1,11 @@ Date: Tue, 16 Mar 2021 23:24:36 +0900 Subject: [PATCH 098/132] test: guest/All --- tests/onsite/General/GuestTest.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/onsite/General/GuestTest.php b/tests/onsite/General/GuestTest.php index 003428cb..371148be 100644 --- a/tests/onsite/General/GuestTest.php +++ b/tests/onsite/General/GuestTest.php @@ -6,6 +6,30 @@ * * /:get /_id:get /_id/log:get */ + +use App\Models\Guest; +use App\Models\Term; +use App\Models\User; + class GuestTest extends TestCase { + public function testGetAll() { + $term_count = 3; + $guest_count = 3; + $user = factory(User::class, 'general')->create(); + + for ($i = 0; $i < $term_count; $i++) { + $term[] = factory(Term::class)->create(); + for ($j = 0; $j < $guest_count; $j++) { + $guest[] = factory(Guest::class)->create([ + 'term_id' => $term[$i]->id + ]); + } + } + $this->actingAs($user)->get('/onsite/general/guest'); + $this->assertResponseOk(); + $this->receiveJson(); + $res = json_decode($this->response->getContent()); + $this->assertCount($term_count * $guest_count, $res); + } } From acbb0fe0659356da3450262cc620a11e9104672f Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Mon, 15 Mar 2021 20:00:00 +0900 Subject: [PATCH 099/132] fix: remove unnessesary "/" from path --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 867b5cba..7cf44c8e 100644 --- a/routes/web.php +++ b/routes/web.php @@ -51,7 +51,7 @@ }); $router->group(['prefix' => 'general', 'middleware' => 'auth:general'], function () use ($router) { - $router->get('guest/', ['uses' => 'GuestController@index']); + $router->get('guest', ['uses' => 'GuestController@index']); $router->get('guest/{id}', ['uses' => 'GuestController@show']); $router->get('guest/{id}/log', ['uses' => 'GuestController@showLog']); $router->post('enter', ['uses' => 'GuestController@enter']); From 068b7f50e5a9cc808ab19c327d91e7173de733ad Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Fri, 19 Mar 2021 22:21:46 +0900 Subject: [PATCH 100/132] fix: onsite/general/exh/status --- .../Controllers/ExhibitionRoomController.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/ExhibitionRoomController.php b/app/Http/Controllers/ExhibitionRoomController.php index 358ecbde..5e912968 100644 --- a/app/Http/Controllers/ExhibitionRoomController.php +++ b/app/Http/Controllers/ExhibitionRoomController.php @@ -13,18 +13,24 @@ class ExhibitionRoomController extends Controller { public function index() { - $exh_status = ExhibitionRoom::all(); - $terms = array(); - foreach ($exh_status as $exh) { + $exh_status = []; + $all_counts = array(); + $all_limit = 0; + foreach (ExhibitionRoom::all() as $exh) { $exh_term = $exh->countGuest(); foreach ($exh_term as $id => $count) { - if (isset($terms[$id])) $terms[$id] += $count; - else $terms[$id] = $count; + if (isset($all_counts[$id])) $all_counts[$id] += $count; + else $all_counts[$id] = $count; } + $all_limit += $exh->capacity; + $exh_status[$exh->id] = new ExhibitionRoomResource($exh); } return response()->json([ 'exh' => $exh_status, - 'all' => $terms + 'all' => [ + 'count' => $all_counts, + 'limit' => $all_limit + ] ]); } From 2289510889e959baec39e60566faadd08d040c73 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Fri, 19 Mar 2021 22:25:08 +0900 Subject: [PATCH 101/132] fix: exhibition cannot use term get --- routes/web.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/routes/web.php b/routes/web.php index 7cf44c8e..2f7646f2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -50,13 +50,15 @@ $router->get('{id}/check', ['uses' => 'ReservationController@check', 'middleware' => 'auth:reservation,general']); }); - $router->group(['prefix' => 'general', 'middleware' => 'auth:general'], function () use ($router) { - $router->get('guest', ['uses' => 'GuestController@index']); - $router->get('guest/{id}', ['uses' => 'GuestController@show']); - $router->get('guest/{id}/log', ['uses' => 'GuestController@showLog']); - $router->post('enter', ['uses' => 'GuestController@enter']); - $router->post('exit', ['uses' => 'GuestController@exit']); - $router->get('term', ['uses' => 'TermController@index']); + $router->group(['prefix' => 'general'], function () use ($router) { + $router->group(['middleware' => 'auth:general'], function () use ($router) { + $router->get('guest', ['uses' => 'GuestController@index']); + $router->get('guest/{id}', ['uses' => 'GuestController@show']); + $router->get('guest/{id}/log', ['uses' => 'GuestController@showLog']); + $router->post('enter', ['uses' => 'GuestController@enter']); + $router->post('exit', ['uses' => 'GuestController@exit']); + }); + $router->get('term', ['uses' => 'TermController@index', 'middleware' => 'auth:general,exhibition']); }); $router->group(['prefix' => 'exhibition'], function () use ($router) { From 602023e3ca90aea6f3e8afa63aff8c2cdc4d3b5b Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Fri, 19 Mar 2021 22:38:08 +0900 Subject: [PATCH 102/132] feat/refactor: term resource --- app/Http/Controllers/TermController.php | 3 ++- app/Http/Resources/GuestResource.php | 2 +- app/Http/Resources/TermResource.php | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 app/Http/Resources/TermResource.php diff --git a/app/Http/Controllers/TermController.php b/app/Http/Controllers/TermController.php index 1fd223c8..fafd813f 100644 --- a/app/Http/Controllers/TermController.php +++ b/app/Http/Controllers/TermController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Http\Resources\TermResource; use App\Models\Term; class TermController extends Controller { @@ -16,6 +17,6 @@ public function index() { ]; } - return response()->json($result); + return response()->json(TermResource::collection($terms)); } } diff --git a/app/Http/Resources/GuestResource.php b/app/Http/Resources/GuestResource.php index b22a397e..c6b43f63 100644 --- a/app/Http/Resources/GuestResource.php +++ b/app/Http/Resources/GuestResource.php @@ -15,7 +15,7 @@ class GuestResource extends Resource { public function toArray($request) { return [ 'id' => $this->id, - 'term' => $this->term, + 'term' => new TermResource($this->term), 'entered_at' => $this->entered_at, 'exited_at' => $this->exited_at, 'exh_id' =>$this->exh_id, diff --git a/app/Http/Resources/TermResource.php b/app/Http/Resources/TermResource.php new file mode 100644 index 00000000..6677a63e --- /dev/null +++ b/app/Http/Resources/TermResource.php @@ -0,0 +1,22 @@ + $this->enter_scheduled_time, + "exit_scheduled_time" => $this->exit_scheduled_time, + "prefix" => config('onsite.guest_types')[$this->guest_type]['prefix'] + ]; + } +} From ac0030b99010be8ae9b20658d46c0a899a5ba90d Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Fri, 19 Mar 2021 22:39:01 +0900 Subject: [PATCH 103/132] fix: return guest type --- app/Http/Resources/TermResource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Resources/TermResource.php b/app/Http/Resources/TermResource.php index 6677a63e..c4fbd52e 100644 --- a/app/Http/Resources/TermResource.php +++ b/app/Http/Resources/TermResource.php @@ -16,7 +16,7 @@ public function toArray($request) { return [ "enter_scheduled_time" => $this->enter_scheduled_time, "exit_scheduled_time" => $this->exit_scheduled_time, - "prefix" => config('onsite.guest_types')[$this->guest_type]['prefix'] + "guest_type" => $this->guest_type ]; } } From 8291970f595428e8eeedb10f0ddd6e7f85dd8659 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Fri, 19 Mar 2021 23:25:56 +0900 Subject: [PATCH 104/132] fix: return term obj --- app/Http/Controllers/TermController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/TermController.php b/app/Http/Controllers/TermController.php index fafd813f..8e95ac4f 100644 --- a/app/Http/Controllers/TermController.php +++ b/app/Http/Controllers/TermController.php @@ -17,6 +17,6 @@ public function index() { ]; } - return response()->json(TermResource::collection($terms)); + return response()->json($result); } } From 0aba8a92f27995eaf937519b30413b909fb86cd4 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Fri, 19 Mar 2021 23:28:43 +0900 Subject: [PATCH 105/132] fix: rename GuestGray to StudentGray --- config/onsite.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/onsite.php b/config/onsite.php index c8186ea6..8a5d3704 100644 --- a/config/onsite.php +++ b/config/onsite.php @@ -32,7 +32,7 @@ 'GuestWhite' => [ 'prefix' => 'GW' ], - 'GuestGray' => [ + 'StudentGray' => [ 'prefix' => 'SG' ], 'TestBlue' => [ From cead771589029a7144aa02d6eef68d1b6d826dc2 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Fri, 19 Mar 2021 23:35:50 +0900 Subject: [PATCH 106/132] fix: return guest_type in term/all --- app/Http/Controllers/TermController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/TermController.php b/app/Http/Controllers/TermController.php index 8e95ac4f..8f27a916 100644 --- a/app/Http/Controllers/TermController.php +++ b/app/Http/Controllers/TermController.php @@ -13,7 +13,7 @@ public function index() { $result[$term->id] = [ "enter_scheduled_time" => $term->enter_scheduled_time, "exit_scheduled_time" => $term->exit_scheduled_time, - "prefix" => config('onsite.guest_types')[$term->guest_type]['prefix'] + "guest_type" => config('onsite.guest_types')[$term->guest_type]['prefix'] ]; } From 10fc13388146dd9ea46bee49495c31c6cfd22ca0 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Fri, 19 Mar 2021 23:37:09 +0900 Subject: [PATCH 107/132] fix: return guest_type OBJ in term/all --- app/Http/Controllers/TermController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/TermController.php b/app/Http/Controllers/TermController.php index 8f27a916..f49af90d 100644 --- a/app/Http/Controllers/TermController.php +++ b/app/Http/Controllers/TermController.php @@ -13,7 +13,7 @@ public function index() { $result[$term->id] = [ "enter_scheduled_time" => $term->enter_scheduled_time, "exit_scheduled_time" => $term->exit_scheduled_time, - "guest_type" => config('onsite.guest_types')[$term->guest_type]['prefix'] + "guest_type" => $term->guest_type ]; } From 88953baed886d9ef017fe2b3ab5a7db87bfad918 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Fri, 19 Mar 2021 23:50:39 +0900 Subject: [PATCH 108/132] fix: return all guest counts --- app/Http/Controllers/ExhibitionRoomController.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/ExhibitionRoomController.php b/app/Http/Controllers/ExhibitionRoomController.php index 5e912968..542e1c9b 100644 --- a/app/Http/Controllers/ExhibitionRoomController.php +++ b/app/Http/Controllers/ExhibitionRoomController.php @@ -7,6 +7,7 @@ use App\Http\Resources\GuestResource; use App\Models\ExhibitionRoom; use App\Models\Guest; +use App\Models\Term; use Illuminate\Http\Request; use Carbon\Carbon; use App\Models\ActivityLog; @@ -14,17 +15,17 @@ class ExhibitionRoomController extends Controller { public function index() { $exh_status = []; - $all_counts = array(); $all_limit = 0; foreach (ExhibitionRoom::all() as $exh) { - $exh_term = $exh->countGuest(); - foreach ($exh_term as $id => $count) { - if (isset($all_counts[$id])) $all_counts[$id] += $count; - else $all_counts[$id] = $count; - } $all_limit += $exh->capacity; $exh_status[$exh->id] = new ExhibitionRoomResource($exh); } + + $all_counts = []; + foreach (Term::all() as $term) { + $cnt = Guest::query()->where('term_id', $term->id)->count(); + if ($cnt !== 0) $all_counts[$term->id] = $cnt; + } return response()->json([ 'exh' => $exh_status, 'all' => [ From 0fd4e3cb473d2c032b616a679f17c4c9305a3adc Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 20 Mar 2021 06:36:21 +0900 Subject: [PATCH 109/132] fix: pass ExhRoom/log through activitylog resource --- app/Http/Controllers/ExhibitionRoomController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/ExhibitionRoomController.php b/app/Http/Controllers/ExhibitionRoomController.php index 542e1c9b..4475dc2b 100644 --- a/app/Http/Controllers/ExhibitionRoomController.php +++ b/app/Http/Controllers/ExhibitionRoomController.php @@ -114,6 +114,6 @@ public function showLog(Request $request) { abort(500, 'ExhibitionRoom Not found'); } $logs = ActivityLog::query()->where('exh_id', $id)->get(); - return response()->json($logs); + return response()->json(ExhibitionRoomResource::collection($logs)); } } From 714f1a95c385860ccb3b5da932f37f3ee2221f00 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 20 Mar 2021 06:51:53 +0900 Subject: [PATCH 110/132] fix: use ActivityLogResource instead of ExhibitionRoom.... --- app/Http/Controllers/ExhibitionRoomController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ExhibitionRoomController.php b/app/Http/Controllers/ExhibitionRoomController.php index 4475dc2b..a45d4f1c 100644 --- a/app/Http/Controllers/ExhibitionRoomController.php +++ b/app/Http/Controllers/ExhibitionRoomController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Exceptions\HttpExceptionWithErrorCode; +use App\Http\Resources\ActivityLogResource; use App\Http\Resources\ExhibitionRoomResource; use App\Http\Resources\GuestResource; use App\Models\ExhibitionRoom; @@ -114,6 +115,6 @@ public function showLog(Request $request) { abort(500, 'ExhibitionRoom Not found'); } $logs = ActivityLog::query()->where('exh_id', $id)->get(); - return response()->json(ExhibitionRoomResource::collection($logs)); + return response()->json(ActivityLogResource::collection($logs)); } } From 2a7dabacd9c9ecd561c371c29e2520729ecdd5cd Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 21 Mar 2021 15:41:30 +0900 Subject: [PATCH 111/132] feat: thumbnail and name column migration --- ...44447_add_name_and_thumbnail_id_column.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 database/migrations/2021_03_20_144447_add_name_and_thumbnail_id_column.php diff --git a/database/migrations/2021_03_20_144447_add_name_and_thumbnail_id_column.php b/database/migrations/2021_03_20_144447_add_name_and_thumbnail_id_column.php new file mode 100644 index 00000000..6a6987b3 --- /dev/null +++ b/database/migrations/2021_03_20_144447_add_name_and_thumbnail_id_column.php @@ -0,0 +1,32 @@ +string('name')->nullable(); + $table->string('thumbnail_image_id')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() { + Schema::table('exh_rooms', function (Blueprint $table) { + $table->dropColumn('name'); + $table->dropColumn('thumbnail_image_id'); + }); + } +} From 72eaf387de1f3a9d2b3d34fb37af3b704c8b8156 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 21 Mar 2021 15:42:20 +0900 Subject: [PATCH 112/132] feat: return thumbnail_id, name data in exhroom --- app/Http/Resources/ExhibitionRoomResource.php | 6 +++++- app/Models/ExhibitionRoom.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Http/Resources/ExhibitionRoomResource.php b/app/Http/Resources/ExhibitionRoomResource.php index dd3676a1..02f69df2 100644 --- a/app/Http/Resources/ExhibitionRoomResource.php +++ b/app/Http/Resources/ExhibitionRoomResource.php @@ -14,9 +14,13 @@ class ExhibitionRoomResource extends Resource { */ public function toArray($request) { return [ + 'info' => [ + 'name' => $this->name, + 'room_id' => $this->room_id, + 'thumbnail_image_id' => $this->thumbnail_image_id, + ], 'count' => $this->countGuest(), 'limit' => $this->capacity, - 'room_id' => $this->room_id, ]; } } diff --git a/app/Models/ExhibitionRoom.php b/app/Models/ExhibitionRoom.php index 4d2e5c28..68bbfb77 100644 --- a/app/Models/ExhibitionRoom.php +++ b/app/Models/ExhibitionRoom.php @@ -13,7 +13,7 @@ class ExhibitionRoom extends Model { */ protected $fillable = [ - 'id', 'room_id', 'capacity', 'guest_count', 'updated_at', + 'id', 'name', 'room_id', 'capacity', 'guest_count', 'updated_at', 'thumbnail_image_id', ]; /** From 943cfb466da89fef0c08dfeeb1f13460e89874d3 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 21 Mar 2021 16:01:14 +0900 Subject: [PATCH 113/132] feat: activity log path --- .../Controllers/ActivityLogController.php | 32 +++++++++++++++++++ routes/web.php | 1 + 2 files changed, 33 insertions(+) create mode 100644 app/Http/Controllers/ActivityLogController.php diff --git a/app/Http/Controllers/ActivityLogController.php b/app/Http/Controllers/ActivityLogController.php new file mode 100644 index 00000000..5fd69cbe --- /dev/null +++ b/app/Http/Controllers/ActivityLogController.php @@ -0,0 +1,32 @@ +validate($request, [ + 'id' => ['string'], + 'timestamp' => ['string'], + 'guest_id' => ['int'], + 'exh_id' => ['string'], + 'log_type' => ['string'], + 'reservation_id' => ['string'], + ]); + $response = ActivityLog::query(); + + if ($request->has('reservation_id') && !$request->user()->hasPermission()) + abort(403); + + return response()->json(ActivityLogResource::collection($response->get())); + } +} diff --git a/routes/web.php b/routes/web.php index 2f7646f2..34641599 100644 --- a/routes/web.php +++ b/routes/web.php @@ -59,6 +59,7 @@ $router->post('exit', ['uses' => 'GuestController@exit']); }); $router->get('term', ['uses' => 'TermController@index', 'middleware' => 'auth:general,exhibition']); + $router->get('log', ['uses' => 'TermController@index', 'middleware' => 'auth:general,exhibition']); }); $router->group(['prefix' => 'exhibition'], function () use ($router) { From dc8feca548449b60f785ed9c87bc5c4b75ec07f9 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 21 Mar 2021 16:15:08 +0900 Subject: [PATCH 114/132] fix: controller name --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 34641599..589b0cb1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -59,7 +59,7 @@ $router->post('exit', ['uses' => 'GuestController@exit']); }); $router->get('term', ['uses' => 'TermController@index', 'middleware' => 'auth:general,exhibition']); - $router->get('log', ['uses' => 'TermController@index', 'middleware' => 'auth:general,exhibition']); + $router->get('log', ['uses' => 'ActivityLogController@index', 'middleware' => 'auth:general,exhibition']); }); $router->group(['prefix' => 'exhibition'], function () use ($router) { From e3f5077f7064e247133d4ea5972a2d3d76a48f3d Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Mon, 22 Mar 2021 23:33:33 +0900 Subject: [PATCH 115/132] fix: set dates attribute --- app/Models/Term.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Models/Term.php b/app/Models/Term.php index 9e2e7a85..0d2cf93f 100644 --- a/app/Models/Term.php +++ b/app/Models/Term.php @@ -29,4 +29,9 @@ class Term extends Model { public $incrementing = false; public $timestamps = false; + + protected $dates = [ + 'enter_scheduled_time', + 'exit_scheduled_time', + ]; } From 7d5d6408a387e2aec3e61fdda43c3ef3dd46907d Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Wed, 24 Mar 2021 22:44:27 +0900 Subject: [PATCH 116/132] fix: count only who have not exited --- app/Http/Controllers/ExhibitionRoomController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/ExhibitionRoomController.php b/app/Http/Controllers/ExhibitionRoomController.php index a45d4f1c..0ba76505 100644 --- a/app/Http/Controllers/ExhibitionRoomController.php +++ b/app/Http/Controllers/ExhibitionRoomController.php @@ -24,7 +24,7 @@ public function index() { $all_counts = []; foreach (Term::all() as $term) { - $cnt = Guest::query()->where('term_id', $term->id)->count(); + $cnt = Guest::query()->whereNull('exited_at')->where('term_id', $term->id)->count(); if ($cnt !== 0) $all_counts[$term->id] = $cnt; } return response()->json([ From 44c4f3f0800465efcda6639e472e5834dbda0819 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Thu, 25 Mar 2021 18:45:33 +0900 Subject: [PATCH 117/132] feat: check valid character --- app/Http/Controllers/GuestController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/GuestController.php b/app/Http/Controllers/GuestController.php index 2e24d250..aaeb59f9 100644 --- a/app/Http/Controllers/GuestController.php +++ b/app/Http/Controllers/GuestController.php @@ -31,7 +31,7 @@ public function enter(Request $request) { 'guest_id' => ['string', 'required'] ]); - if (!preg_match('/^[A-Z]{2,3}-[a-zA-Z0-9]{5}$/', $request->guest_id)) { + if (!preg_match('/^[A-Z]{2,3}-[2-578ac-kmnpr-z]{5}$/', $request->guest_id)) { throw new HttpExceptionWithErrorCode(400, 'INVALID_WRISTBAND_CODE'); } From b39ada9d78d302d2595142d784ae892620b4cfc0 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Thu, 25 Mar 2021 19:21:17 +0900 Subject: [PATCH 118/132] feat: use only valid reservation Id --- app/Http/Controllers/ReservationController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ReservationController.php b/app/Http/Controllers/ReservationController.php index 02416ed0..8d54df46 100644 --- a/app/Http/Controllers/ReservationController.php +++ b/app/Http/Controllers/ReservationController.php @@ -37,8 +37,12 @@ public function create(Request $request) { 'cellphone' => ['required', 'string', 'regex:/0\d{9,10}$/'] ]); + $salt = "234578acdefghijkmnprstuvwxyz"; do { - $reservation_id = 'R-'.Str::random(10); + $reservation_id = 'R-'; + while (strlen($reservation_id) < 10) { + $reservation_id .= $salt[mt_rand(0, strlen($salt) - 1)]; + } } while (Reservation::where('id', $reservation_id)->exists()); $reservation = Reservation::create( From 237e4ce5ebe5d6c61edb87bd7bcd5f1afd009d91 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Thu, 25 Mar 2021 19:37:32 +0900 Subject: [PATCH 119/132] test: Guest/Show --- tests/onsite/General/GuestTest.php | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/onsite/General/GuestTest.php b/tests/onsite/General/GuestTest.php index 371148be..247bbb59 100644 --- a/tests/onsite/General/GuestTest.php +++ b/tests/onsite/General/GuestTest.php @@ -10,6 +10,7 @@ use App\Models\Guest; use App\Models\Term; use App\Models\User; +use Illuminate\Support\Carbon; class GuestTest extends TestCase { public function testGetAll() { @@ -32,4 +33,34 @@ public function testGetAll() { $res = json_decode($this->response->getContent()); $this->assertCount($term_count * $guest_count, $res); } + + public function testShow() { + $user = factory(User::class, 'general')->create(); + $term = factory(Term::class)->create(); + + $guest = factory(Guest::class)->create([ + 'term_id' => $term->id, + ]); + + $this->actingAs($user)->get('/onsite/general/guest/' . $guest->id); + $this->assertResponseOk(); + $this->receiveJson(); + $res = json_decode($this->response->getContent()); + + $this->seeJsonEquals([ + 'id' => $guest->id, + 'entered_at' => $guest->entered_at, + 'exited_at' => $guest->exited_at, + 'exh_id' => $guest->exh_id, + 'term' => [ + 'enter_scheduled_time' => + $term->enter_scheduled_time + ->rawFormat('Y-m-d\T'.Carbon::getTimeFormatByPrecision('microseconds').'\Z'), + 'exit_scheduled_time' => + $term->exit_scheduled_time + ->rawFormat('Y-m-d\T'.Carbon::getTimeFormatByPrecision('microseconds').'\Z'), + 'guest_type' => $term->guest_type + ] + ]); + } } From 8deb84c88a1e2b82b8de274bd65862442294ebf7 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 27 Mar 2021 09:22:05 +0900 Subject: [PATCH 120/132] fix: timestamp format in term resource --- app/Http/Resources/TermResource.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Resources/TermResource.php b/app/Http/Resources/TermResource.php index c4fbd52e..6386fb29 100644 --- a/app/Http/Resources/TermResource.php +++ b/app/Http/Resources/TermResource.php @@ -14,8 +14,8 @@ class TermResource extends Resource { */ public function toArray($request) { return [ - "enter_scheduled_time" => $this->enter_scheduled_time, - "exit_scheduled_time" => $this->exit_scheduled_time, + "enter_scheduled_time" => $this->enter_scheduled_time->toIso8601ZuluString(), + "exit_scheduled_time" => $this->exit_scheduled_time->toIso8601ZuluString(), "guest_type" => $this->guest_type ]; } From bbb21f4c6f34ff74ff65bacefb402a11ea81c81e Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 27 Mar 2021 09:22:29 +0900 Subject: [PATCH 121/132] test: use Iso8601Zulu Format --- tests/onsite/General/GuestTest.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/onsite/General/GuestTest.php b/tests/onsite/General/GuestTest.php index 247bbb59..c331ceec 100644 --- a/tests/onsite/General/GuestTest.php +++ b/tests/onsite/General/GuestTest.php @@ -53,12 +53,8 @@ public function testShow() { 'exited_at' => $guest->exited_at, 'exh_id' => $guest->exh_id, 'term' => [ - 'enter_scheduled_time' => - $term->enter_scheduled_time - ->rawFormat('Y-m-d\T'.Carbon::getTimeFormatByPrecision('microseconds').'\Z'), - 'exit_scheduled_time' => - $term->exit_scheduled_time - ->rawFormat('Y-m-d\T'.Carbon::getTimeFormatByPrecision('microseconds').'\Z'), + 'enter_scheduled_time' => $term->enter_scheduled_time->toIso8601ZuluString(), + 'exit_scheduled_time' => $term->exit_scheduled_time->toIso8601ZuluString(), 'guest_type' => $term->guest_type ] ]); From ae718dbf1cec39f83742bb586758de28f9d2aed0 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 27 Mar 2021 10:09:00 +0900 Subject: [PATCH 122/132] test-feat: general/GuestNotFound --- tests/onsite/General/GuestTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/onsite/General/GuestTest.php b/tests/onsite/General/GuestTest.php index c331ceec..f9710e8f 100644 --- a/tests/onsite/General/GuestTest.php +++ b/tests/onsite/General/GuestTest.php @@ -11,6 +11,7 @@ use App\Models\Term; use App\Models\User; use Illuminate\Support\Carbon; +use Illuminate\Support\Str; class GuestTest extends TestCase { public function testGetAll() { @@ -59,4 +60,12 @@ public function testShow() { ] ]); } + + public function testNotFound() { + $user = factory(User::class, 'general')->create(); + $id = Str::random(8); + $this->actingAs($user)->get("/onsite/general/guest/$id"); + + $this->assertResponseStatus(404); + } } From 3cb3fe51ed30342c161fc50563fdfcc53202e091 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 27 Mar 2021 10:09:32 +0900 Subject: [PATCH 123/132] test-docs: remove guest/$id/log --- tests/onsite/General/GuestTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/onsite/General/GuestTest.php b/tests/onsite/General/GuestTest.php index f9710e8f..1d05f139 100644 --- a/tests/onsite/General/GuestTest.php +++ b/tests/onsite/General/GuestTest.php @@ -4,7 +4,7 @@ /* * general/guest/* * - * /:get /_id:get /_id/log:get + * /:get /_id:get */ use App\Models\Guest; From 7a25b8daf4645095df22100e101f484d23dff5b6 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 27 Mar 2021 11:03:21 +0900 Subject: [PATCH 124/132] fix: allow reservation to get log --- routes/web.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/web.php b/routes/web.php index 589b0cb1..1765a624 100644 --- a/routes/web.php +++ b/routes/web.php @@ -59,7 +59,7 @@ $router->post('exit', ['uses' => 'GuestController@exit']); }); $router->get('term', ['uses' => 'TermController@index', 'middleware' => 'auth:general,exhibition']); - $router->get('log', ['uses' => 'ActivityLogController@index', 'middleware' => 'auth:general,exhibition']); + $router->get('log', ['uses' => 'ActivityLogController@index', 'middleware' => 'auth:general,exhibition,reservation']); }); $router->group(['prefix' => 'exhibition'], function () use ($router) { From 12b343cc68d8897ded9e6c01fb3a071d53412b41 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 27 Mar 2021 11:04:47 +0900 Subject: [PATCH 125/132] test: log/permission test --- tests/onsite/General/LogTest.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/onsite/General/LogTest.php diff --git a/tests/onsite/General/LogTest.php b/tests/onsite/General/LogTest.php new file mode 100644 index 00000000..5485687f --- /dev/null +++ b/tests/onsite/General/LogTest.php @@ -0,0 +1,25 @@ +create(); + + $this->actingAs($user)->get('/onsite/general/log'); + $this->assertResponseOk(); + } + + foreach (['blogAdmin', 'admin', 'blogWriter', 'teacher'] as $perm) { + $user = factory(User::class, $perm)->create(); + $this->actingAs($user)->get('/onsite/general/log'); + $this->assertResponseStatus(403); + } + } +} From 3b268b2d423a9c1d8d4dfa142092c106bc2f46da Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 27 Mar 2021 21:52:51 +0900 Subject: [PATCH 126/132] test: remove id factory from activityLog --- database/factories/ModelFactory.php | 1 - 1 file changed, 1 deletion(-) diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index cdf537ea..10dd7d96 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -143,7 +143,6 @@ $factory->define(App\Models\ActivityLog::class, function (Faker\Generator $faker) { return [ - 'id'=>$faker->userName, 'timestamp'=>$faker->dateTime, 'exh_id'=>$faker->userName, 'log_type'=>array_rand(['enter','exit']), From d79a24f07af5021602ca225dabd12da26f05712b Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 27 Mar 2021 22:57:45 +0900 Subject: [PATCH 127/132] fix: set modelLog increments true --- app/Models/ActivityLog.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/ActivityLog.php b/app/Models/ActivityLog.php index 117b97d7..d68d03f9 100644 --- a/app/Models/ActivityLog.php +++ b/app/Models/ActivityLog.php @@ -26,7 +26,7 @@ class ActivityLog extends Model { protected $keyType = 'string'; - public $incrementing = false; + public $incrementing = true; public $timestamps = true; From 8dbe2db968a11fa142e36320f64fd1cb40f34f90 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 27 Mar 2021 22:58:04 +0900 Subject: [PATCH 128/132] test: use faker in factory --- database/factories/ModelFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 10dd7d96..559a1b43 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -145,7 +145,7 @@ return [ 'timestamp'=>$faker->dateTime, 'exh_id'=>$faker->userName, - 'log_type'=>array_rand(['enter','exit']), + 'log_type'=>$faker->randomElement(['exit','enter']), 'guest_id'=>$faker->userName, ]; }); From 414a5a65016182623bc32e9dd12ea0b1066da4a8 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sat, 27 Mar 2021 22:58:25 +0900 Subject: [PATCH 129/132] test: ActivityLog/testData --- tests/onsite/General/LogTest.php | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/onsite/General/LogTest.php b/tests/onsite/General/LogTest.php index 5485687f..eab97008 100644 --- a/tests/onsite/General/LogTest.php +++ b/tests/onsite/General/LogTest.php @@ -5,9 +5,46 @@ * general/log/ */ +use App\Http\Resources\GuestResource; +use App\Models\ActivityLog; +use App\Models\Exhibition; +use App\Models\Guest; +use App\Models\Reservation; +use App\Models\Term; use App\Models\User; class LogTest extends TestCase { + public function testData() { + $term = factory(Term::class)->create(); + $reservation = factory(Reservation::class)->create([ + 'term_id' => $term->id + ]); + $guest = factory(Guest::class)->create([ + 'reservation_id' => $reservation->id + ]); + $exh_user = factory(User::class, 'exhibition')->create(); + $exh = factory(Exhibition::class)->create([ + 'id' => $exh_user->id + ]); + $log = factory(ActivityLog::class)->create([ + 'exh_id' => $exh->id, + 'guest_id' => $guest->id, + ]); + + $this->actingAs($exh_user)->get('/onsite/general/log'); + $this->assertResponseOk(); + $this->receiveJson(); + $this->seeJsonEquals([ + [ + 'id' => $log->id, + 'timestamp' => $log->timestamp->toIso8601ZuluString(), + 'exh_id' => $exh->id, + 'guest' => new GuestResource($guest), + 'log_type' => $log->log_type, + ], + ]); + } + public function testGetPermission() { foreach (['general', 'exhibition', 'reservation'] as $perm) { $user = factory(User::class, $perm)->create(); From f20d3d98d234fae3627888d55d0b5cdfb637930a Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Wed, 31 Mar 2021 20:33:24 +0900 Subject: [PATCH 130/132] fix: add useCurrent in term timestamps --- database/migrations/2020_08_25_111818_create_terms_table.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/migrations/2020_08_25_111818_create_terms_table.php b/database/migrations/2020_08_25_111818_create_terms_table.php index feaaba53..b7aa4c76 100644 --- a/database/migrations/2020_08_25_111818_create_terms_table.php +++ b/database/migrations/2020_08_25_111818_create_terms_table.php @@ -15,8 +15,8 @@ public function up() { Schema::create('terms', function (Blueprint $table) { $table->string('id'); $table->primary('id'); - $table->timestamp('enter_scheduled_time'); - $table->timestamp('exit_scheduled_time'); + $table->timestamp('enter_scheduled_time')->useCurrent(); + $table->timestamp('exit_scheduled_time')->useCurrent(); $table->string('color_id'); }); } From e07ae66b4cbf2ad71a6f72b89d0571579d703141 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Thu, 8 Apr 2021 14:45:54 +0900 Subject: [PATCH 131/132] feat: log search --- app/Http/Controllers/ActivityLogController.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/ActivityLogController.php b/app/Http/Controllers/ActivityLogController.php index 5fd69cbe..78b4df53 100644 --- a/app/Http/Controllers/ActivityLogController.php +++ b/app/Http/Controllers/ActivityLogController.php @@ -6,6 +6,7 @@ use App\Http\Resources\ArticleResource; use App\Models\ActivityLog; use App\Models\Article; +use App\Models\Reservation; use App\Models\Revision; use Illuminate\Http\Request; use Laravel\Lumen\Routing\Controller as BaseController; @@ -22,11 +23,20 @@ public function index(Request $request) { 'log_type' => ['string'], 'reservation_id' => ['string'], ]); - $response = ActivityLog::query(); + $log = ActivityLog::query(); - if ($request->has('reservation_id') && !$request->user()->hasPermission()) - abort(403); + foreach ($query as $i => $value) { + if ($i == 'reservation_id') { + if (!$request->user()->hasPermission('reservation')) { + abort(403); + } + if ($reservation = Reservation::find($value)) { + $log->where('guest_id', $reservation->guest->id); + } else return response([]); + } + $log->where($i, $value); + } - return response()->json(ActivityLogResource::collection($response->get())); + return response()->json(ActivityLogResource::collection($log->get())); } } From 28996a8b14eeeee35a32a8a1d9eb645905cbba26 Mon Sep 17 00:00:00 2001 From: Takeno-hito <18237819+Takeno-hito@users.noreply.github.com> Date: Sun, 11 Apr 2021 00:07:28 +0900 Subject: [PATCH 132/132] fix: validate "if string" instead "if int" --- app/Http/Controllers/ActivityLogController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/ActivityLogController.php b/app/Http/Controllers/ActivityLogController.php index 78b4df53..036af468 100644 --- a/app/Http/Controllers/ActivityLogController.php +++ b/app/Http/Controllers/ActivityLogController.php @@ -18,7 +18,7 @@ public function index(Request $request) { $query = $this->validate($request, [ 'id' => ['string'], 'timestamp' => ['string'], - 'guest_id' => ['int'], + 'guest_id' => ['string'], 'exh_id' => ['string'], 'log_type' => ['string'], 'reservation_id' => ['string'],