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