Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 /**
  * parse username to get userid
  * 
  */
 protected function getUserId($username)
 {
     if (starts_with($username, "@:")) {
         return substr($username, 2);
     }
     return \Veer\Models\User::where('username', '=', substr($username, 1))->pluck('id');
 }
Exemplo n.º 3
0
 /**
  * Increment Orders Counts
  */
 protected function incrementOrdersCount($users_id)
 {
     \Veer\Models\User::where('id', '=', $users_id)->increment('orders_count');
 }
Exemplo n.º 4
0
 /**
  * @param array $data
  * @return \Veer\Services\Administration\Elements\User
  */
 public function updateBan($data)
 {
     if (is_array($data) && !empty($data) && key($data) != \Auth::id()) {
         \Veer\Models\User::where('id', '=', key($data))->update(['banned' => head($data)]);
         if (head($data) == true) {
             \Veer\Models\UserAdmin::where('users_id', '=', key($data))->update(['banned' => head($data)]);
         }
         event('veer.message.center', trans('veeradmin.user.ban'));
     }
     return $this;
 }
Exemplo n.º 5
0
 /**
  * parse communications
  */
 protected function parseCommunicationRecipients($recipients)
 {
     if (empty($recipients)) {
         return null;
     }
     $u = json_decode($recipients);
     if (!is_array($u) || is_array($u) && count($u) < 1) {
         return null;
     }
     $getUsers = \Veer\Models\User::whereIn('id', $u)->get();
     $itemsUsers = array();
     foreach ($getUsers as $user) {
         $itemsUsers[$user->id] = $user;
     }
     return $itemsUsers;
 }
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
 /**
  * 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;
 }
 protected function getRecipientsEmails()
 {
     if (is_array($this->recipients)) {
         foreach ($this->recipients as $userId) {
             $email = \Veer\Models\User::where('id', '=', $userId)->pluck('email');
             if (!empty($email)) {
                 $this->emails[] = $email;
             }
         }
     }
 }