Inheritance: extends October\Rain\Auth\Models\User, use trait October\Rain\Database\Traits\SoftDeleting
Exemplo n.º 1
0
 /**
  * Add activity metadata 
  * 
  * @param User $user
  * @param Activity $activity
  * @param array $data    key-value pair data to store
  * @param array $exclude When given exclude keys to be stored in the database
  */
 public static function addUserActivity(User $user, Activity $activity, array $data, array $exclude = [])
 {
     $rows = [];
     $exclude = array_map('strtolower', $exclude);
     // Create a session_id.
     // Session_id is use for easily identify groups of metadata
     $hashids = new Hashids('dma.activity.metadata', 6);
     $user_id = $user->getKey();
     $activity_id = $activity->getKey();
     // Add unixtime and microseconds to avoid session_id collisions
     $micro = microtime(true);
     $unixtime = floor($micro);
     $milseconds = floor(($micro - $unixtime) * pow(10, 8));
     // Create session_id
     $session_id = $hashids->encode($user_id, $activity_id, $unixtime, $milseconds);
     // Current date and time
     $now = date('Y-m-d H:i:s');
     foreach ($data as $key => $value) {
         $key = strtolower($key);
         if (!in_array($key, $exclude)) {
             $row = ['session_id' => $session_id, 'user_id' => $user_id, 'activity_id' => $activity_id, 'key' => $key, 'value' => $value, 'created_at' => $now, 'updated_at' => $now];
             $rows[] = $row;
         }
     }
     if (count($row) > 0) {
         static::insert($rows);
     }
 }
 public function importData($results, $sessionKey = null)
 {
     foreach ($results as $row => $data) {
         $data += ['is_activated' => true];
         if (empty($data['username'])) {
             $data['username'] = $data['email'];
         }
         if (empty($data['password'])) {
             $data['password'] = $data['username'];
         }
         if (empty($data['password_confirmation'])) {
             $data['password_confirmation'] = $data['password'];
         }
         try {
             $user = new User();
             $user->fill($data);
             // try to find avatar
             $avatar = $this->findAvatar($data['username']);
             if ($avatar) {
                 $user->avatar = $avatar;
             }
             // save user
             $user->save();
             // activate user
             $user->attemptActivation($user->activation_code);
             $this->logCreated();
         } catch (\Exception $ex) {
             $this->logError($row, $ex->getMessage());
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Automatically creates a metadata entry for a user if not one already.
  * @param  RainLab\User\Models\User $user
  * @return DMA\Friends\Models\Usermeta
  */
 public static function getFromUser($user = null)
 {
     if (!$user) {
         return null;
     }
     if (!$user->metadata) {
         $meta = new static();
         User::find($user->getKey())->metadata()->save($meta);
         $user = User::find($user->getKey());
     }
     return $user->metadata;
 }
Exemplo n.º 4
0
 public function onStart()
 {
     $user_id = $this->param('id');
     $user_id = $user_id == 'default' ? 1 : $user_id;
     $this['cur_id'] = $user_id;
     $this['cur_user'] = User::findOrFail($user_id);
 }
Exemplo n.º 5
0
 public function boot()
 {
     User::extend(function ($model) {
         $model->hasOne['forum_member'] = ['RainLab\\Forum\\Models\\Member'];
         $model->bindEvent('model.beforeDelete', function () use($model) {
             $model->forum_member && $model->forum_member->delete();
         });
     });
     UsersController::extendFormFields(function ($widget, $model, $context) {
         // Prevent extending of related form instead of the intended User form
         if (!$widget->model instanceof \RainLab\User\Models\User) {
             return;
         }
         if ($context != 'update') {
             return;
         }
         if (!Member::getFromUser($model)) {
             return;
         }
         $widget->addFields(['forum_member[username]' => ['label' => 'rainlab.forum::lang.settings.username', 'tab' => 'Forum', 'comment' => 'rainlab.forum::lang.settings.username_comment'], 'forum_member[is_moderator]' => ['label' => 'rainlab.forum::lang.settings.moderator', 'type' => 'checkbox', 'tab' => 'Forum', 'span' => 'auto', 'comment' => 'rainlab.forum::lang.settings.moderator_comment'], 'forum_member[is_banned]' => ['label' => 'rainlab.forum::lang.settings.banned', 'type' => 'checkbox', 'tab' => 'Forum', 'span' => 'auto', 'comment' => 'rainlab.forum::lang.settings.banned_comment']], 'primary');
     });
     UsersController::extendListColumns(function ($widget, $model) {
         if (!$model instanceof \RainLab\User\Models\User) {
             return;
         }
         $widget->addColumns(['forum_member_username' => ['label' => 'rainlab.forum::lang.settings.forum_username', 'relation' => 'forum_member', 'select' => 'username', 'searchable' => false]]);
     });
 }
Exemplo n.º 6
0
Arquivo: Plugin.php Projeto: jiiis/ptn
 public function boot()
 {
     User::extend(function ($model) {
         $model->hasMany['flynsarmy_sociallogin_providers'] = ['Flynsarmy\\SocialLogin\\Models\\Provider'];
     });
     Event::listen('backend.form.extendFields', function (Form $form) {
         if (!$form->getController() instanceof \System\Controllers\Settings) {
             return;
         }
         if (!$form->model instanceof \Flynsarmy\SocialLogin\Models\Settings) {
             return;
         }
         foreach (ProviderManager::instance()->listProviders() as $class => $details) {
             $classObj = $class::instance();
             $classObj->extendSettingsForm($form);
         }
     });
     Event::listen('backend.form.extendFields', function ($widget) {
         if (!$widget->getController() instanceof \RainLab\User\Controllers\Users) {
             return;
         }
         if ($widget->getContext() != 'update') {
             return;
         }
         $widget->addFields(['flynsarmy_sociallogin_providers' => ['label' => 'Social Providers', 'type' => 'Flynsarmy\\SocialLogin\\FormWidgets\\LoginProviders']], 'secondary');
     });
 }
 protected function loadData()
 {
     $days = $this->property('days');
     if (!$days) {
         throw new ApplicationException('Invalid days value: ' . $days);
     }
     // all accesses for last month
     $items = User::where('created_at', '>=', Carbon::now()->subDays($days)->format('Y-m-d'))->get();
     // parse data
     $all = [];
     foreach ($items as $item) {
         // date
         $timestamp = strtotime($item->created_at) * 1000;
         $day = Carbon::createFromFormat('Y-m-d H:i:s', $item->created_at)->format('Y-m-d');
         if (isset($all[$day])) {
             $all[$day][1]++;
         } else {
             $all[$day] = [$timestamp, 1];
         }
     }
     // count all
     $all_render = [];
     foreach ($all as $a) {
         $all_render[] = [$a[0], $a[1]];
     }
     return $all_render;
 }
Exemplo n.º 8
0
 public function boot()
 {
     // Alias
     $alias = AliasLoader::getInstance();
     $alias->alias('Carbon', '\\Carbon\\Carbon');
     // $alias->alias('DB', '\Barryvdh\Debugbar\Facade');
     $alias->alias('CW', '\\Clockwork\\Support\\Laravel\\Facade');
     // User model extend
     UserModel::extend(function ($model) {
         $model->addFillable(['phone', 'patronymic']);
         $model->hasOne['profile'] = ['Abnmt\\MRC\\Models\\Profile'];
         $model->hasMany['orders'] = ['Abnmt\\MRC\\Models\\Order'];
         $model->hasMany['userevents'] = ['Abnmt\\MRC\\Models\\UserEvent'];
         $model->hasManyThrough['courses'] = ['Abnmt\\MRC\\Models\\Event', 'through' => 'Abnmt\\MRC\\Models\\UserEvent'];
         $model->hasManyThrough['events'] = ['Abnmt\\MRC\\Models\\Event', 'through' => 'Abnmt\\MRC\\Models\\UserEvent'];
     });
     // User controller extend Form
     UsersController::extendFormFields(function ($widget) {
         // $configFile = __DIR__ . '/config/profile_fields.yaml';
         // $config = Yaml::parse(File::get($configFile));
         $config = ['phone' => ['label' => 'Телефон', 'span' => 'auto'], 'patronymic' => ['label' => 'Отчество', 'span' => 'auto']];
         $widget->addFields($config);
     });
     // User controller extend List
     UsersController::extendListColumns(function ($list, $model) {
         if (!$model instanceof UserModel) {
             return;
         }
         $config = ['surname' => ['label' => 'Фамилия'], 'patronymic' => ['label' => 'Отчество'], 'phone' => ['label' => 'Телефон']];
         $list->addColumns($config);
     });
 }
Exemplo n.º 9
0
 /**
  * Execute the console command.
  * @throws Exception
  */
 public function fire()
 {
     $login = $this->argument('login');
     if ($this->rainlab) {
         $rainlab = (bool) $this->option('rainlab');
     } else {
         $rainlab = false;
     }
     if ($rainlab) {
         $user = \RainLab\User\Models\User::where('email', '=', $login)->orWhere('username', '=', $login)->first();
     } else {
         $user = User::whereLogin($login)->first();
     }
     if (!$user) {
         return $this->error('User not found');
     }
     $password = $this->option('password');
     if ($rainlab) {
         $login = '******' . $login;
     } else {
         $login = '******' . $login;
     }
     if ($password == null) {
         $password = $this->ask('Set password for ' . $login . ' (or press Enter to skip)');
     }
     if ($password == null) {
         $password = Str::random(5);
     }
     $user->update(['password' => $password, 'password_confirmation' => $password]);
     $message = "\n  -> new password for " . $login . ": ";
     $this->comment($message . $password);
     return;
 }
Exemplo n.º 10
0
 public function boot()
 {
     UserModel::extend(function ($model) {
         $model->hasOne['profile'] = ['KurtJensen\\Profile\\Models\\Profile', 'key' => 'user_id', 'otherKey' => 'id'];
     });
     UsersController::extendFormFields(function ($form, $model, $context) {
         if (!$model instanceof UserModel) {
             return;
         }
         if (!$model->exists) {
             return;
         }
         if ($form->getContext() != 'update') {
             return;
         }
         if (!ProfileModel::getFromUser($form->model)) {
             return;
         }
         // Flash::success($model->profile->created_at);
         // Ensure that a profile model always exists
         ProfileModel::getFromUser($model);
         $groupsField = $form->getField('groups');
         $form->removeField('groups');
         $form->addTabFields(['primary_usergroup' => ['label' => 'Primary User Group', 'comment' => 'Set the primary group association for this user.', 'tab' => 'rainlab.user::lang.user.account', 'type' => 'dropdown', 'options' => $this->getPrimaryUsergroupOptions()], 'groups' => ['label' => 'Groups/Roles', 'tab' => 'rainlab.user::lang.user.account', 'type' => 'relation', 'emptyOption' => 'There are no user groups available.'], 'profile[per_text_1]' => ['label' => Settings::get('per_label_1', 'Place of Birth'), 'comment' => Settings::get('per_desc_1', 'The town you were born in.'), 'tab' => 'Personal', 'type' => Settings::get('per_typ_1', 'text'), 'options' => ['test' => 'test', 'test2' => 'test2', 'custom' => 'custom']], 'profile[per_text_2]' => ['label' => Settings::get('per_label_2', 'Favorite Activity'), 'comment' => Settings::get('per_desc_2', 'The thing you like to do most.'), 'tab' => 'Personal', 'type' => Settings::get('per_typ_2', 'text')], 'profile[per_text_3]' => ['label' => Settings::get('per_label_3', 'About Me'), 'comment' => Settings::get('per_desc_3', 'All about you.'), 'tab' => 'Personal', 'type' => Settings::get('per_typ_3', 'textarea')], 'profile[per_text_4]' => ['label' => Settings::get('per_label_4', 'Hobbies'), 'comment' => Settings::get('per_desc_4', 'How you invest in your free time.'), 'tab' => 'Personal', 'type' => Settings::get('per_typ_4', 'textarea')], 'profile[pro_text_1]' => ['label' => Settings::get('pro_label_1', 'Position'), 'comment' => Settings::get('pro_desc_1', 'Your current job title.'), 'tab' => 'Professional', 'type' => Settings::get('pro_typ_1', 'text')], 'profile[pro_text_2]' => ['label' => Settings::get('pro_label_2', 'Assignment'), 'comment' => Settings::get('pro_desc_2', 'Where are you working now.'), 'tab' => 'Professional', 'type' => Settings::get('pro_typ_2', 'text')], 'profile[pro_text_3]' => ['label' => Settings::get('pro_label_3', 'Accomplishments'), 'comment' => Settings::get('pro_desc_3', 'The positive things you have done so far.'), 'tab' => 'Professional', 'type' => Settings::get('pro_typ_3', 'textarea')], 'profile[pro_text_4]' => ['label' => Settings::get('pro_label_4', 'Future Goals'), 'comment' => Settings::get('pro_desc_4', 'The things you want to accomplish in the next year or more.'), 'tab' => 'Professional', 'type' => Settings::get('pro_typ_4', 'textarea')]]);
     });
     Event::listen('backend.menu.extendItems', function ($manager) {
         $manager->addSideMenuItems('RainLab.User', 'user', ['merge' => ['label' => 'Merge', 'icon' => 'icon-exchange', 'code' => 'merge', 'owner' => 'RainLab.User', 'url' => Backend::url('kurtjensen/profile/merge'), 'permissions' => ['kurtjensen.profile.merge']]]);
     });
 }
Exemplo n.º 11
0
 /**
  * {@inheritDoc}
  */
 public function render()
 {
     $limit = $this->property('limit');
     $users = User::orderBy('points_today', 'DESC')->take($limit)->get();
     $this->vars['users'] = $users;
     return $this->makePartial('widget');
 }
Exemplo n.º 12
0
 public function postValidPincode()
 {
     if (!Auth::check()) {
         return Response::json(array('status' => 'error', 'message' => trans(CLF_LANG_MESSAGE . 'require_signin')), 500);
     }
     if (!Input::has('pincode')) {
         return;
     }
     $rules = array('pincode' => 'required|alpha_num|size:4');
     if ($response = self::valid($rules)) {
         return Response::json($response);
     }
     //$phone_number = Input::get('phone_number');
     $user_id = Auth::getUser()->id;
     $pincode = Input::get('pincode');
     // Get pincode inactive
     $check = Pincode::getLastPincodeInActive($user_id, $pincode);
     if ($check && !empty($check->phone_number)) {
         // Exists pincode inactive in db
         if (Pincode::ActivePincode($check->phone_number)) {
             // Update user has actived
             $user = User::where('id', $user_id)->update(array('is_validated' => 1, 'phone_number' => $check->phone_number));
             if (isset($user->errors)) {
                 return Response::json(response_message(400, $user->errors()->first()), 400);
             }
         }
         return Response::json(response_message(200));
     } else {
         return Response::json(response_message(1006));
     }
 }
Exemplo n.º 13
0
 public function onRun()
 {
     $users = User::with(['metadata' => function ($query) {
         $query->where('current_member', '!=', Usermeta::IS_STAFF);
     }])->orderBy('points_today', 'desc')->take(10)->get();
     $this->page['users'] = $users;
 }
 public function exportData($columns, $sessionKey = null)
 {
     $users = User::all();
     $users->each(function ($user) use($columns) {
         $user->addVisible($columns);
     });
     return $users->toArray();
 }
 protected function loadData()
 {
     $days = $this->property('days');
     if (!$days) {
         throw new ApplicationException('Invalid days value: ' . $days);
     }
     // all accesses for last month
     $items = AccessLog::where('created_at', '>=', Carbon::now()->subDays($days)->format('Y-m-d'))->get();
     // parse data
     $all = [];
     $users = [];
     $user_rows = [];
     foreach ($items as $item) {
         // user
         $user_id = $item->user_id ? $item->user_id : 0;
         $users[$user_id] = $user_id > 0 ? User::find($user_id) : $this->getDeletedFakeUser();
         // date
         $timestamp = strtotime($item->created_at) * 1000;
         $day = Carbon::createFromFormat('Y-m-d H:i:s', $item->created_at)->format('Y-m-d');
         if (isset($user_rows[$user_id][$day])) {
             $user_rows[$user_id][$day][1]++;
         } else {
             $user_rows[$user_id][$day] = [$timestamp, 1];
         }
         // init empty day
         if (!isset($all[$day])) {
             $all[$day] = ['timestamp' => $timestamp, 'date' => $day, 'count' => 0];
         }
         // increase count
         $all[$day]['count']++;
     }
     // we need at least two days, to display chart
     if (sizeof($all) == 1) {
         $day = reset($all);
         $date = Carbon::createFromFormat('Y-m-d', $day['date'])->subDays(1);
         $dateFormated = $date->format('Y-m-d');
         $all[$dateFormated] = ['timestamp' => $date->timestamp * 1000, 'date' => $dateFormated, 'count' => 0];
     }
     // transform user line to json
     foreach ($user_rows as $key => $user_row) {
         $rows = [];
         foreach ($user_row as $row) {
             $rows[] = [$row[0], $row[1]];
         }
         // we need at least two days, to display chart
         if (sizeof($rows) == 1) {
             $first = reset($rows);
             $rows[] = [$first[0] - 86400000, 0];
         }
         $user_rows[$key] = $rows;
     }
     // count all
     $all_render = [];
     foreach ($all as $a) {
         $all_render[] = [$a['timestamp'], $a['count']];
     }
     return ['all' => $all_render, 'user_rows' => $user_rows, 'users' => $users];
 }
Exemplo n.º 16
0
 public function getUserAttribute()
 {
     $user_name = '';
     if (isset($this->attribute['user_id'])) {
         $user = User::find($this->attribute['user_id']);
         $user_name = $user->name;
     }
     return $user_name;
 }
Exemplo n.º 17
0
 public function boot()
 {
     App::register('Laravel\\Cashier\\CashierServiceProvider');
     Config::set('services.stripe.model', 'RainLab\\User\\Models\\User');
     Config::set('services.stripe.secret', Settings::get('stripe_secret'));
     User::extend(function ($model) {
         $model->implement[] = 'Alxy.Cashier.Behaviors.BillableModel';
     });
 }
Exemplo n.º 18
0
 public function __construct()
 {
     parent::__construct();
     BackendMenu::setContext('Klubitus.Calendar', 'calendar', 'import');
     SettingsManager::setContext('Klubitus.Calendar', 'settings');
     $this->vars['importEnabled'] = $this->importEnabled = (bool) CalendarSettings::get('facebook_import_enabled');
     $this->vars['importUrl'] = $this->importUrl = CalendarSettings::get('facebook_import_url');
     $this->vars['importUser'] = $this->importUser = UserModel::find(CalendarSettings::get('facebook_import_user_id'));
 }
Exemplo n.º 19
0
 public function run()
 {
     //
     // @todo
     //
     // Add a Welcome post or something
     //
     Category::create(['name' => trans('rainlab.blog::lang.categories.uncategorized'), 'slug' => 'uncategorized']);
     IMsg::create(['user_id' => User::orderBy('id', 'desc')->first()->id, 'content' => '初始化信息第一条']);
 }
Exemplo n.º 20
0
 public function render()
 {
     $friends = User::count();
     $optin = Usermeta::where('email_optin', 1)->count();
     $notOptin = $friends - $optin;
     $this->vars['optin'] = number_format($optin);
     $this->vars['notOptin'] = number_format($notOptin);
     $this->vars['percent'] = round($optin / $friends * 100) . '%';
     return $this->makePartial('widget');
 }
Exemplo n.º 21
0
 public function render()
 {
     $friends = User::count();
     $partners = Usermeta::select('id')->where('current_member', Usermeta::IS_MEMBER)->count();
     $notPartners = $friends - $partners;
     $this->vars['totalFriends'] = number_format($friends);
     $this->vars['notPartners'] = number_format($notPartners);
     $this->vars['partners'] = number_format($partners);
     $this->vars['partnerPercent'] = round($partners / $friends * 100) . '%';
     return $this->makePartial('widget');
 }
Exemplo n.º 22
0
 /** 
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     User::chunk(500, function ($users) {
         foreach ($users as $user) {
             if (strlen($user->barcode_id) > 10) {
                 $user->barcode_id = substr($user->barcode_id, 0, 9);
                 $user->forceSave();
             }
         }
     });
 }
Exemplo n.º 23
0
 public function getUserIdOptions($keyValue = null)
 {
     $manager = PluginManager::instance();
     if ($manager->exists('rainlab.user')) {
         $Users = array();
         foreach (UserModel::orderBy('surname')->orderBy('name')->get() as $user) {
             $Users[$user->id] = $user->surname . ', ' . $user->name;
         }
         return $Users;
     }
     return [0 => 'Rainlab User Model Not Installed'];
 }
Exemplo n.º 24
0
 public function boot()
 {
     UserModel::extend(function ($model) {
         $model->addFillable(['phone', 'mobile', 'company', 'street_addr', 'city', 'zip']);
         $model->implement[] = 'RainLab.Location.Behaviors.LocationModel';
     });
     UsersController::extendFormFields(function ($widget) {
         $configFile = __DIR__ . '/config/profile_fields.yaml';
         $config = Yaml::parse(File::get($configFile));
         $widget->addTabFields($config);
     });
 }
Exemplo n.º 25
0
 public function loadUserInfo()
 {
     $peopleWithAvatars = [];
     $avatars = Avatar::where('attachment_type', 'RainLab\\User\\Models\\User')->where('field', 'avatar')->get();
     foreach ($avatars as $avatr) {
         $this->avatars[$avatr->attachment_id] = ['t600' => $avatr->getThumb(600, 600), 't200' => $avatr->getThumb(200, 200), 'filename' => $avatr->filename];
         $peopleWithAvatars[] = $avatr->attachment_id;
     }
     // Set Pagination parameters
     $this->perPage = $this->property('PicsPerPage', 12);
     $this->currentPage = input('page', 1);
     $sort3 = null;
     /*
      * Sorting
      */
     switch ($this->sort) {
         case 'last':
             $sort1 = 'surname';
             $sort2 = 'name';
             break;
         case 'given':
             $sort1 = 'name';
             $sort2 = 'surname';
             break;
         default:
             $sort1 = 'primary_usergroup';
             $sort2 = 'surname';
             $sort3 = 'name';
     }
     $people = user::wherein('id', $peopleWithAvatars)->orderBy($sort1)->orderBy($sort2);
     if ($sort3) {
         $people->orderBy($sort3);
     }
     $this->people = $people->paginate($this->perPage, $this->currentPage);
     /*
      * Pagination
      */
     if ($this->people) {
         $queryArr = [];
         $queryArr['sort'] = $this->sort;
         $queryArr['page'] = '';
         $paginationUrl = Request::url() . '?' . http_build_query($queryArr);
         if ($this->currentPage > ($this->lastPage = $this->people->lastPage()) && $this->currentPage > 1) {
             return Redirect::to($paginationUrl . $this->lastPage);
         }
         $this->firstItem = $this->people->firstItem();
         $this->lastItem = $this->people->lastItem();
         $this->total = $this->people->total();
         $this->paginationUrl = $paginationUrl;
     }
     return $this->people;
 }
Exemplo n.º 26
0
 /**
  * {@inheritDoc}
  */
 public function render()
 {
     $today = date('Y-m-d');
     $thisWeek = date('Y-m-d', strtotime('last monday'));
     $this->addCss('css/friendstoolbar.css');
     $meta = new Usermeta();
     $meta_table = $meta->getTable();
     $this->vars['numFriends'] = Usermeta::where('current_member', '!=', Usermeta::IS_STAFF)->count();
     $this->vars['todayFriends'] = User::join($meta_table, 'users.id', '=', $meta_table . '.user_id')->where('current_member', '!=', Usermeta::IS_STAFF)->where('created_at', '>=', $today)->count();
     $this->vars['weekFriends'] = User::join($meta_table, 'users.id', '=', $meta_table . '.user_id')->where('current_member', '!=', Usermeta::IS_STAFF)->where('created_at', '>=', $thisWeek)->count();
     $this->vars['averageFriends'] = $this->getAverageFriends();
     return $this->makePartial('widget');
 }
Exemplo n.º 27
0
 public function boot()
 {
     UserModel::extend(function ($model) {
         $model->addFillable(['iu_gender', 'iu_telephone', 'iu_job', 'iu_company', 'iu_about', 'iu_webpage', 'iu_blog', 'iu_facebook', 'iu_twitter', 'iu_skype', 'iu_icq', 'iu_comment']);
     });
     UsersController::extendFormFields(function ($form, $model, $context) {
         if (!$model instanceof UserModel) {
             return;
         }
         $form->addTabFields(['iu_gender' => ['label' => 'indikator.user::lang.personal.gender', 'tab' => 'indikator.user::lang.personal.tab', 'type' => 'dropdown', 'options' => ['unknown' => Lang::get('indikator.user::lang.gender.unknown'), 'female' => Lang::get('indikator.user::lang.gender.female'), 'male' => Lang::get('indikator.user::lang.gender.male')], 'span' => 'auto'], 'iu_telephone' => ['label' => 'indikator.user::lang.personal.telephone', 'tab' => 'indikator.user::lang.personal.tab', 'span' => 'auto'], 'iu_job' => ['label' => 'indikator.user::lang.personal.job', 'tab' => 'indikator.user::lang.personal.tab', 'span' => 'auto'], 'iu_company' => ['label' => 'indikator.user::lang.personal.company', 'tab' => 'indikator.user::lang.personal.tab', 'span' => 'auto'], 'iu_about' => ['label' => 'indikator.user::lang.personal.about', 'tab' => 'indikator.user::lang.personal.tab', 'type' => 'textarea', 'size' => 'small', 'span' => 'full'], 'iu_webpage' => ['label' => 'indikator.user::lang.internet.webpage', 'tab' => 'indikator.user::lang.internet.tab', 'span' => 'auto'], 'iu_blog' => ['label' => 'indikator.user::lang.internet.blog', 'tab' => 'indikator.user::lang.internet.tab', 'span' => 'auto'], 'iu_facebook' => ['label' => 'indikator.user::lang.internet.facebook', 'tab' => 'indikator.user::lang.internet.tab', 'span' => 'auto'], 'iu_twitter' => ['label' => 'indikator.user::lang.internet.twitter', 'tab' => 'indikator.user::lang.internet.tab', 'span' => 'auto'], 'iu_skype' => ['label' => 'indikator.user::lang.internet.skype', 'tab' => 'indikator.user::lang.internet.tab', 'span' => 'auto'], 'iu_icq' => ['label' => 'indikator.user::lang.internet.icq', 'tab' => 'indikator.user::lang.internet.tab', 'span' => 'auto']]);
         $form->addSecondaryTabFields(['iu_comment' => ['label' => 'indikator.user::lang.comment', 'type' => 'textarea', 'size' => 'small']]);
     });
 }
Exemplo n.º 28
0
 public static function get_user_charge_money($user_id = 0)
 {
     if (!$user_id) {
         return 0;
     }
     $user = User::find($user_id);
     $money_account = $user->money_charge - $user->money_spent;
     if ($money_account > 0) {
         return $money_account;
     } else {
         return 0;
     }
 }
Exemplo n.º 29
0
 /**
  * Update Events from CRM
  */
 public function onUpdateFromCrm()
 {
     $crmuserevents = CRMUserEvent::isNotUpdated()->with(['user', 'event'])->get();
     \CW::info(['userevents' => $crmuserevents]);
     if (count($crmuserevents) == 0) {
         Flash::info("No UserEvents to Create/Update");
         // echo "ERROR!";
         return;
     }
     $crmuserevents->each(function ($userevent) {
         if ($userevent->user && $userevent->event) {
             \CW::info([$userevent]);
             $cmsuser = User::where('email', $userevent->user->email)->first();
             $cmsevent = Event::where('crm_event_id', $userevent->event->id)->with('course')->first();
             $cmscourse = $cmsevent->course;
             $cmsusereventstate = UserEventState::where('crm_state_id', $userevent->state_id)->first();
             // $cmsuserevent = UserEvent::firstOrNew(['crm_event_id' => $userevent->event->id, 'user_id' => $cmsuser->id]);
             // $cmsuserevent = $cmsuser->userevents()
             // $cmsuserevent = $cmsuserevent
             $cmsuserevent = UserEvent::where('user_id', $cmsuser->id)->where('event_id', $cmsevent->id)->first();
             if (!$cmsuserevent) {
                 $cmsuserevent = new UserEvent();
             }
             \CW::info([$cmsuser, $cmsevent, $cmscourse, $cmsuserevent, $cmsusereventstate]);
             // if (!$cmsuser) {
             //     Log::warning("CMSUser is NULL\n");
             // }
             // if (!$cmsevent) {
             //     Log::warning("CMSEvent is NULL\n");
             // }
             // if (!$cmscourse) {
             //     Log::warning("CMSCourse is NULL\n");
             // }
             // if (!$cmsuserevent) {
             //     Log::warning("CMSUserEvent is NULL\n");
             // }
             // if (!$cmsusereventstate) {
             //     Log::warning("CMSUserEventState is NULL\n");
             // }
             $cmsuserevent->user()->associate($cmsuser);
             $cmsuserevent->course()->associate($cmscourse);
             $cmsuserevent->state()->associate($cmsusereventstate);
             $cmsuserevent->event()->associate($cmsevent);
             $cmsuserevent->fill(['course_type_id' => $cmscourse->course_type_id, 'course_category_id' => $cmscourse->course_category_id, 'crm_event_id' => $userevent->event->id]);
             \CW::info([$cmsuserevent]);
             $cmsuserevent->save();
             $userevent->update(['is_updated' => true]);
         }
     });
     Flash::success("UserEvents is update");
 }
 protected function synchronizeUser()
 {
     $alwaysUpdate = $this->option('force-update');
     $this->progressbar = $this->getHelperSet()->get('progress');
     $this->progressbar->start($this->output, User::count());
     User::chunk(500, function ($users) use($alwaysUpdate) {
         foreach ($users as $user) {
             $this->progressbar->advance();
             $email = $user->email;
             MailChimpIntegration::syncMemberToMailChimp($email, $user, false);
         }
     });
     ${$this}->progressbar->finish();
 }