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