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