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