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