This repository was archived by the owner on Oct 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
#85 入退場管理/予約システムの仮置 #138
Draft
Takeno-hito
wants to merge
138
commits into
develop
Choose a base branch
from
feature/#85_afes_manage
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
#85 入退場管理/予約システムの仮置 #138
Changes from all commits
Commits
Show all changes
138 commits
Select commit
Hold shift + click to select a range
7575738
feat: create reservations table migration
Takeno-hito 2ef93f0
feat: create guests table migration
Takeno-hito 09cd76c
feat: create activity_logs table migration
Takeno-hito f6af791
fix: to follow new doccument from afes-website/docs
Takeno-hito e1f094b
feat: create terms migration
Takeno-hito 1ca1817
feat: add 4 models
Takeno-hito 93396ff
fix: reservation model and reservation migration
Takeno-hito 62f3f20
feat: add reservation create route
Takeno-hito 06b9c1c
fix: to response if query has unnessesary content
Takeno-hito e90fd7a
feat: add reservation with private resource
Takeno-hito 89c24bd
feat: add reservation resource
Takeno-hito 0548652
feat: add reservation search method
Takeno-hito 17b90a7
feat: add reservation show method
Takeno-hito 1b2648c
feat: create HttpExceptionWithError
Takeno-hito 8d04b6d
feat: add general/enter path about guest
Takeno-hito 86ebd71
feat: add general exit method
Takeno-hito dac29c8
feat: craete manage config and write color
Takeno-hito 27dd420
fix: add manage config
Takeno-hito 772fb4a
feat: check wrong_wristband_color
Takeno-hito 679cdf8
docs: change reservation prefix
Takeno-hito 291aadc
fix: to use in MySQL
Takeno-hito af0942d
feat: now check wrish_band code
Takeno-hito c8c7e78
Merge branch 'develop' into feature/#85_afes_manage
Takeno-hito d381cb4
feat: add guest resource
Takeno-hito d796f58
feat: add guest show path
Takeno-hito 2c39b07
feat: add guest index route
Takeno-hito 358ad48
fix: change guestId format to (XX-XXXXX)
Takeno-hito 5885af1
feat: update afes/docs
Takeno-hito e3bb6da
feat: Wristband prefix check
Takeno-hito 7b2013b
feat: ALREADY_ENTERED_RESERVATION error
Takeno-hito c5c41e1
fix: problem of throw with not 400 code in guest/enter
Takeno-hito f978b2b
fix: don't always return WRONG_WRISTBAND_COLOR
su8ru 0eac1a2
feat: reservetion->hasProblem method
Takeno-hito 76c98ba
feat: reservation check
Takeno-hito 9c6b312
feat: exhibition room model/migration
Takeno-hito f08e6a8
fix: set table name in exh_room model
Takeno-hito 0b6aef0
feat: exhroom model: guest_relation
Takeno-hito ff3e792
feat: permission settings
Takeno-hito 90d659c
feat: exhibition show
Takeno-hito 6728172
feat: exhibition enter
Takeno-hito 5bb84ff
feat: exhibition exit
Takeno-hito f5a5685
feat: activity_log resource
Takeno-hito 59e13a3
fix: pass through resource in guest/exit, showlog
Takeno-hito 069e95c
feat: 404 in guest/show_log
Takeno-hito 8e4d314
fix: exhroom/exit: remove duplicate validation
Takeno-hito 581418c
feat: exhibition/log
Takeno-hito e2a88bb
fix: set permission to general
Takeno-hito 010ba50
feat: set permission to online/exhibition
Takeno-hito 05b7ab1
feat: term controller
Takeno-hito 4efd4d7
refactor: remove unused implements
Takeno-hito 8fd4f14
refactor: remove unused import
Takeno-hito 26fb005
fix: remove message arg in Httpexception_with_error_code
Takeno-hito 387c44b
style: make the if expression one line
Takeno-hito 49f69f3
style: remove unnessesary ()
Takeno-hito 895dcc8
refactor: rename reserv to reservation
Takeno-hito 0eeebeb
refactor: use strpos instead of regex
Takeno-hito 720a5bd
fix: stop quitting writing php with adding = in !=
Takeno-hito 90fb815
fix: remove unused expression
Takeno-hito 7d57f3a
fix: rename to clarify method usage
Takeno-hito 3c46658
refactor: use do-while in generating reservation-id
Takeno-hito 9939319
fix: remove unused method in guest resource
Takeno-hito ac29262
fix: to accept enter when the time as same as enter_scheduled_time
Takeno-hito 9b78368
refactor: rename config/manage to config/onsite
Takeno-hito b6c0a33
refactor: use group in router
Takeno-hito e777fe3
Merge branch 'develop' into feature/#85_afes_manage
Takeno-hito d4fade3
refactor: fix by phpcbf / phpcs
Takeno-hito b4c8b72
feat: exhibition room controller index
Takeno-hito 669926e
fix: use getErrorCode
Takeno-hito 6a226ad
fix: use correct controller
Takeno-hito f006c59
feat: term index
Takeno-hito 06950fb
Merge branch 'develop' into feature/#85_afes_manage
Takeno-hito cf7ecc1
feat: return term object
Takeno-hito f097e8a
fix: return prefix in term info
Takeno-hito 0ef0ab6
fix: rename violet color to purple
Takeno-hito 2e77fc2
fix: rename color_id to guest_type
Takeno-hito 2a847d3
test: create onsite factories
Takeno-hito d574548
test: fix model factory
Takeno-hito de1d62e
test: create guest entrance enter
Takeno-hito e459ac7
test: move "generalEntranceTest" to "general/EntranceTest"
Takeno-hito c96b8cc
test: create InvalidGuestCodeCheck
Takeno-hito d932bbd
fix: use term instead of term_id
Takeno-hito d14b2f9
fix: return term in reservation/check
Takeno-hito 967120f
test: fix: flip args of assertEquals
Takeno-hito 9a0b80f
test: generl/enter/alreadyUsedGuestCode
Takeno-hito 68ae7b9
test: generl/enter/notFoundReservation
Takeno-hito 6900aec
test: generl/enter/AlreadyEnteredReservation
Takeno-hito 1cafa15
test: generl/enter/OutOfReservationTime
Takeno-hito c8f9baf
test: generl/enter/WrongWristBandColor
Takeno-hito 10ff4ab
feat: EXHIBITION_NOT_FOUND
Takeno-hito 0905444
fix: return status code instead of 404/409
Takeno-hito fdece4e
Merge branch 'develop' into feature/#85_afes_manage
Takeno-hito 306a7ef
style: auto fix by phpcbf
Takeno-hito f2513d0
test: test when entertime is over
Takeno-hito ef826fb
Merge branch 'develop' into feature/#85_afes_manage
Takeno-hito 8edbdad
test: general/exit
Takeno-hito bfabdb0
test: general/exit/GuestNotFound
Takeno-hito cd61c8c
test: general/exit/GuestAlreadyExited
Takeno-hito 8de13a9
style: fix by phpcs
Takeno-hito 67b7513
test: entrance forbidden
Takeno-hito 167e6ea
test: entrance guest
Takeno-hito 658417b
test: create GuestTest
Takeno-hito c92422c
test: add path description
Takeno-hito b025de9
test: guest/All
Takeno-hito acbb0fe
fix: remove unnessesary "/" from path
Takeno-hito 068b7f5
fix: onsite/general/exh/status
Takeno-hito 2289510
fix: exhibition cannot use term get
Takeno-hito 602023e
feat/refactor: term resource
Takeno-hito ac0030b
fix: return guest type
Takeno-hito 8291970
fix: return term obj
Takeno-hito 0aba8a9
fix: rename GuestGray to StudentGray
Takeno-hito cead771
fix: return guest_type in term/all
Takeno-hito 10fc133
fix: return guest_type OBJ in term/all
Takeno-hito 88953ba
fix: return all guest counts
Takeno-hito 0fd4e3c
fix: pass ExhRoom/log through activitylog resource
Takeno-hito 714f1a9
fix: use ActivityLogResource instead of ExhibitionRoom....
Takeno-hito 2a7daba
feat: thumbnail and name column migration
Takeno-hito 72eaf38
feat: return thumbnail_id, name data in exhroom
Takeno-hito 943cfb4
feat: activity log path
Takeno-hito dc8feca
fix: controller name
Takeno-hito e3f5077
fix: set dates attribute
Takeno-hito 7d5d640
fix: count only who have not exited
Takeno-hito 44c4f3f
feat: check valid character
Takeno-hito b39ada9
feat: use only valid reservation Id
Takeno-hito 237e4ce
test: Guest/Show
Takeno-hito 8deb84c
fix: timestamp format in term resource
Takeno-hito bbb21f4
test: use Iso8601Zulu Format
Takeno-hito ae718db
test-feat: general/GuestNotFound
Takeno-hito 3cb3fe5
test-docs: remove guest/$id/log
Takeno-hito 7a25b8d
fix: allow reservation to get log
Takeno-hito 12b343c
test: log/permission test
Takeno-hito 3b268b2
test: remove id factory from activityLog
Takeno-hito d79a24f
fix: set modelLog increments true
Takeno-hito 8dbe2db
test: use faker in factory
Takeno-hito 414a5a6
test: ActivityLog/testData
Takeno-hito f20d3d9
fix: add useCurrent in term timestamps
Takeno-hito 34a86f8
Merge branch 'develop' into HEAD
Takeno-hito e07ae66
feat: log search
Takeno-hito 28996a8
fix: validate "if string" instead "if int"
Takeno-hito File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <?php | ||
|
|
||
|
|
||
| namespace App\Exceptions; | ||
|
|
||
| use Symfony\Component\HttpKernel\Exception\HttpException; | ||
|
|
||
| class HttpExceptionWithErrorCode extends HttpException { | ||
| private $errorCode; | ||
|
|
||
| public function __construct($httpCode, $errorCode) { | ||
| $this->errorCode = $errorCode; | ||
|
|
||
| parent::__construct($httpCode); | ||
| } | ||
|
|
||
| public function getErrorCode() { | ||
| return $this->errorCode; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| <?php | ||
|
|
||
| namespace App\Http\Controllers; | ||
|
|
||
| use App\Http\Resources\ActivityLogResource; | ||
| 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; | ||
| use Carbon\Carbon; | ||
|
|
||
| class ActivityLogController extends BaseController { | ||
|
|
||
| public function index(Request $request) { | ||
| $query = $this->validate($request, [ | ||
| 'id' => ['string'], | ||
| 'timestamp' => ['string'], | ||
| 'guest_id' => ['string'], | ||
| 'exh_id' => ['string'], | ||
| 'log_type' => ['string'], | ||
| 'reservation_id' => ['string'], | ||
| ]); | ||
| $log = ActivityLog::query(); | ||
|
|
||
| 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($log->get())); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| <?php | ||
|
|
||
| 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; | ||
| use App\Models\Guest; | ||
| use App\Models\Term; | ||
| use Illuminate\Http\Request; | ||
| use Carbon\Carbon; | ||
| use App\Models\ActivityLog; | ||
|
|
||
| class ExhibitionRoomController extends Controller { | ||
| public function index() { | ||
| $exh_status = []; | ||
| $all_limit = 0; | ||
| foreach (ExhibitionRoom::all() as $exh) { | ||
| $all_limit += $exh->capacity; | ||
| $exh_status[$exh->id] = new ExhibitionRoomResource($exh); | ||
| } | ||
|
|
||
| $all_counts = []; | ||
| foreach (Term::all() as $term) { | ||
| $cnt = Guest::query()->whereNull('exited_at')->where('term_id', $term->id)->count(); | ||
| if ($cnt !== 0) $all_counts[$term->id] = $cnt; | ||
| } | ||
| return response()->json([ | ||
| 'exh' => $exh_status, | ||
| 'all' => [ | ||
| 'count' => $all_counts, | ||
| 'limit' => $all_limit | ||
| ] | ||
| ]); | ||
| } | ||
|
|
||
| public function show(Request $request, $id) { | ||
| $exhibition = ExhibitionRoom::find($id); | ||
| if (!$exhibition) { | ||
| abort(404); | ||
| } | ||
|
|
||
| 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 (!$exh) throw new HttpExceptionWithErrorCode(400, 'EXHIBITION_NOT_FOUND'); | ||
| 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)); | ||
| } | ||
|
|
||
| public function exit(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); | ||
|
|
||
| if (!$exh) throw new HttpExceptionWithErrorCode(400, 'EXHIBITION_NOT_FOUND'); | ||
| 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)); | ||
| } | ||
|
|
||
| public function showLog(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(); | ||
su8ru marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return response()->json(ActivityLogResource::collection($logs)); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| <?php | ||
|
|
||
| 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\Reservation; | ||
| use Illuminate\Http\Request; | ||
| use Carbon\Carbon; | ||
| use App\Models\ActivityLog; | ||
|
|
||
| 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 index() { | ||
| return response()->json(GuestResource::collection(Guest::all())); | ||
| } | ||
|
|
||
| public function enter(Request $request) { | ||
| $this->validate($request, [ | ||
| 'reservation_id' => ['string', 'required'], | ||
| 'guest_id' => ['string', 'required'] | ||
| ]); | ||
|
|
||
| if (!preg_match('/^[A-Z]{2,3}-[2-578ac-kmnpr-z]{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'); | ||
|
|
||
| $reservation_error_code = $reservation->getErrorCode(); | ||
|
|
||
| if ($reservation_error_code !== null) { | ||
| throw new HttpExceptionWithErrorCode(400, $reservation_error_code); | ||
| } | ||
|
|
||
| if (Guest::find($request->guest_id)) { | ||
| throw new HttpExceptionWithErrorCode(400, 'ALREADY_USED_WRISTBAND'); | ||
| } | ||
|
|
||
| $term = $reservation->term; | ||
|
|
||
| if (strpos($request->guest_id, config('onsite.guest_types')[$term->guest_type]['prefix']) !== 0 | ||
| ) { | ||
| throw new HttpExceptionWithErrorCode(400, 'WRONG_WRISTBAND_COLOR'); | ||
| } | ||
|
|
||
|
|
||
| $guest = Guest::create( | ||
| [ | ||
| 'id' => $request->guest_id, | ||
| 'term_id' => $term->id, | ||
| 'reservation_id' => $request->reservation_id | ||
| ] | ||
| ); | ||
|
|
||
| // TODO: 複数人で処理するときの扱いを考える (docsの編集待ち) | ||
| $reservation->update(['guest_id' => $guest->id]); | ||
|
|
||
| return response()->json(new GuestResource($guest)); | ||
| } | ||
|
|
||
| public function exit(Request $request) { | ||
| $this->validate($request, [ | ||
| 'guest_id' => ['string', 'required'] | ||
| ]); | ||
|
|
||
| $guest = Guest::find($request->guest_id); | ||
| if (!$guest) { | ||
| throw new HttpExceptionWithErrorCode(400, 'GUEST_NOT_FOUND'); | ||
| } | ||
|
|
||
| if ($guest->exited_at !== null) { | ||
| throw new HttpExceptionWithErrorCode(400, 'GUEST_ALREADY_EXITED'); | ||
| } | ||
|
|
||
| $guest->update(['exited_at' => Carbon::now()]); | ||
|
|
||
| return response()->json(new GuestResource($guest)); | ||
| } | ||
|
|
||
| public function showLog(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)); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| <?php | ||
|
|
||
| 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; | ||
|
|
||
| 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) $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'], | ||
| 'term_id' => ['required', 'string'], | ||
| 'people_count' => ['required', 'integer', 'gte:1'], | ||
| 'name' => ['required', 'string'], | ||
| 'address' => ['required', 'string'], | ||
| 'cellphone' => ['required', 'string', 'regex:/0\d{9,10}$/'] | ||
| ]); | ||
|
|
||
| $salt = "234578acdefghijkmnprstuvwxyz"; | ||
| do { | ||
| $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( | ||
| array_merge($body, ['id' => $reservation_id]) | ||
| ); | ||
|
|
||
| return response($reservation, 201); | ||
| } | ||
|
|
||
| public function show($id) { | ||
| $reservation = Reservation::find($id); | ||
| if (!$reservation) abort(404); | ||
|
|
||
| return response()->json(new ReservationWithPrivateResource($reservation)); | ||
| } | ||
|
|
||
| public function check($id) { | ||
| $reservation = Reservation::find($id); | ||
| if (!$reservation) abort(404); | ||
|
|
||
| $status_code = $reservation->getErrorCode(); | ||
| if ($status_code !== null) { | ||
| $valid = false; | ||
| } else { | ||
| $valid = true; | ||
| } | ||
|
|
||
| $res = [ | ||
| 'valid' => $valid, | ||
| 'status_code' => $status_code, | ||
| 'term' => $reservation->term | ||
| ]; | ||
|
|
||
| return response()->json($res); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.