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