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