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