/** * * @return mixed */ protected function one() { $this->id = Input::get('id'); $fill = Input::has('fill') ? $this->prepareData(Input::get('fill')) : null; if ($this->action == "add") { // @todo test $user = $this->validateAndCreate($fill); } else { $user = \Veer\Models\User::find($this->id); } if (!is_object($user)) { return event('veer.message.center', trans('veeradmin.error.model.not.found')); } if (!empty($fill)) { $user->fill($fill); } $user->save(); $this->id = $user->id; $this->user = $user; $this->goThroughEverything(); if ($this->action == "add") { app('veer')->skipShow = true; Input::replace(['id' => $this->id]); return \Redirect::route('admin.show', ['users', 'id' => $this->id]); } }
public function add($data, $relation = null, $attach_id = null, $returnId = true) { $prefix = 'fl'; $model = null; switch ($relation) { case 'products': $model = \Veer\Models\Product::find($attach_id); $prefix = 'prd'; break; case 'pages': $model = \Veer\Models\Page::find($attach_id); $prefix = 'pg'; break; case 'categories': $model = \Veer\Models\Category::find($attach_id); $prefix = 'ct'; break; case 'users': $model = \Veer\Models\User::find($attach_id); $prefix = 'usr'; break; } $id = $this->upload('image', 'uploadImage', $attach_id, $model, $prefix, null, is_object($model) ? false : true, $data); return $returnId ? $id : $this; }
public function getUserAdvanced($user, $options = array()) { if ($user == "new") { return new \stdClass(); } $items = \Veer\Models\User::find($user); if (is_object($items)) { $this->loadUserRelations($items); $this->loadSiteTitle($items); $this->loadImagesWithElements($items, array_get($options, 'skipWith', false)); $items['files'] = $this->getOrderDownloads($items->orders); $items['basket'] = $items->userlists()->where('name', '=', '[basket]')->count(); $items['lists'] = $items->userlists()->where('name', '!=', '[basket]')->count(); if (empty(app('veer')->loadedComponents['billsTypes'])) { $this->getExistingBillTemplates(); } } return $items; }
/** * Delete User * */ protected function deleteUser($id) { if ($id == \Auth::id()) { return false; } $u = \Veer\Models\User::find($id); if (is_object($u)) { $u->discounts()->update(["status" => "canceled"]); $u->userlists()->update(["users_id" => false]); $u->books()->update(["users_id" => false]); $u->images()->detach(); $u->searches()->detach(); $u->administrator()->delete(); // don't update: orders, bills, pages, comments, communications // do not need: site, role $u->delete(); return true; } return false; }