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