Example #1
0
 public function destroy($tableId)
 {
     $table = Table::find($tableId)->delete();
     if (!$table) {
         return $this->responseNotFound(['Table Id not found']);
     }
     return $this->responseOk($table);
 }
Example #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $guestChunks = Guest::all()->chunk(6, true);
     foreach ($guestChunks as $index => $chunk) {
         $table = Table::find($index + 1);
         foreach ($chunk as $guest) {
             $table->seatGuest($guest);
         }
     }
 }
Example #3
0
 /**
  * Show Edit Page
  *
  * @Get("crud/{id}/edit", as="crud.edit")
  */
 public function edit($id)
 {
     $crud = Table::find($id);
     return view('crud.edit', compact('crud'));
 }
Example #4
0
 public function seatGuest(Request $request, $eventId, $tableId)
 {
     $guest = Guest::find(Input::get('guest_id'));
     if ($guest->table_id) {
         return $this->respondExistingRelationship('Guest is already seated at ' . $guest->table->table_name);
     }
     $table = Table::find($tableId);
     if ($table->seatGuest($guest)) {
         return $this->prepareResponse('success', $guest->getName() . ' now seated at ' . $table->table_name);
     } else {
         return $this->prepareResponse('error', $table->table_name . ' is full');
     }
 }