action = $action; $this->request = $request; $this->model = $appointment; $this->function = Str::camel($action); $this->executeAction(); return $this->model; } public function store(Appointment $appointment, array $request) { $attributes = $request; $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $appointment = $appointment->create($attributes); return $appointment; } public function update(Appointment $appointment, array $request) { $attributes = $request; $appointment->update($attributes); return $appointment; } public function destroy(Appointment $appointment, array $request) { $appointment->delete(); return $appointment; } public function copy(Appointment $appointment, array $request) { $count = $request['count'] ?: 1; if ($count == 1) { $appointment = $appointment->replicate(); $appointment->created_at = Carbon::now(); $appointment->save(); return $appointment; } for ($i = 1; $i <= $count; $i++) { $new = $appointment->replicate(); $new->created_at = Carbon::now(); $new->save(); } return $appointment; } }