Example #1
0
 protected static function boot()
 {
     parent::boot();
     static::deleting(function ($user) {
         $user->comments()->delete();
     });
 }
Example #2
0
 /**
  * The "booting" method of the model.
  *
  * @return void
  */
 protected static function boot()
 {
     parent::boot();
     static::addGlobalScope('latest', function (Builder $builder) {
         $builder->orderBy('contributors.created_at', 'desc');
     });
 }
Example #3
0
 public static function boot()
 {
     parent::boot();
     static::creating(function ($user) {
         $user->sp_id = 1;
         $cookie = \Cookie::get('sponsor');
         if ($cookie) {
             $user->sp_id = $cookie['user_id'];
         }
         $user->activation_code = str_random(60);
     });
     static::created(function ($user) {
         $access_token = config('services.fbapp.app_id') . '|' . config('services.fbapp.app_secret');
         $fbID = $user->facebook_user_id;
         if (!empty($fbID)) {
             $fb = app(\SammyK\LaravelFacebookSdk\LaravelFacebookSdk::class);
             $response1 = $fb->post('/' . $fbID . '/notifications', array('template' => 'Welcome @[' . $fbID . '] to Essensa Naturale!', 'href' => '@' . $user->username, 'access_token' => $access_token));
         }
         if (empty($fbID)) {
             $fbID = $user->username;
         } else {
             $fbID = '@[' . $fbID . ']';
         }
         $sponsor = $user->sponsor();
         $fbID1 = $sponsor->facebook_user_id;
         if (!empty($fbID1)) {
             $fb = app(\SammyK\LaravelFacebookSdk\LaravelFacebookSdk::class);
             $response2 = $fb->post('/' . $fbID1 . '/notifications', array('template' => 'Congratulations!  @[' . $fbID1 . '] ,' . $fbID . ' Have Signed Up in Your Link!', 'href' => '@' . $sponsor->username, 'access_token' => $access_token));
         }
     });
 }
Example #4
0
File: User.php Project: slicvic/wgg
 /**
  * Override the method to ignore the remember token.
  */
 public function setAttribute($key, $value)
 {
     $isRememberTokenAttribute = $key == $this->getRememberTokenName();
     if (!$isRememberTokenAttribute) {
         parent::setAttribute($key, $value);
     }
 }
Example #5
0
 public function postFavorite(Request $request)
 {
     if ($request->input('toggle') == 'u') {
         $existanceCheck = UserFavorites::where('user_id', '=', Auth::user()->id)->where('favorited_id', '=', $request->input('user'))->count();
         if ($existanceCheck) {
             $follow = UserFavorites::where('user_id', '=', Auth::user()->id)->where('favorited_id', '=', $request->input('user'))->first();
             $follow->delete();
             $user = User::find($request->input('user'));
             $user->favorites--;
             $user->save();
             echo 'ok';
         } else {
             echo 'error';
         }
     } elseif ($request->input('toggle') == 'f') {
         $existanceCheck = UserFavorites::where('user_id', '=', Auth::user()->id)->where('favorited_id', '=', $request->input('user'))->count();
         if (!$existanceCheck) {
             $follow = new UserFavorites();
             $follow->user_id = Auth::user()->id;
             $follow->favorited_id = $request->input('user');
             $follow->save();
             $user = User::find($request->input('user'));
             $user->favorites++;
             $user->save();
             echo 'ok';
         } else {
             echo 'error';
         }
     }
 }
Example #6
0
 /**
  * Sobreescribimos lo que sucede al momento de crear un nuevo usuario
  */
 public static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         $model->uuid = Uuid::generate(4);
     });
 }
 public function edit($id)
 {
     $mill = Mill::find($id);
     $users = User::lists('name', 'id');
     // dd($user);
     return view('admin.mealedit', compact('mill', 'users'));
 }
Example #8
0
 public function __construct(array $attributes = [])
 {
     parent::__construct($attributes);
     $this->websiteId = Session::get('website_id');
     $this->defaultWebsiteId = Session::get('default_website_id');
     $this->isDefaultWebsite = Session::get('is_default_website');
 }
 /**
  * The "booting" method of the model.
  *
  * @return void
  */
 protected static function boot()
 {
     parent::boot();
     static::creating(function ($model) {
         $model->username_lowercase = strtolower($model->username);
     });
 }
Example #10
0
 /**
  *
  */
 public static function boot()
 {
     parent::boot();
     User::creating(function ($user) {
         $user->salt = CryptoLib::genSaltBase64();
     });
 }
Example #11
0
 public static function boot()
 {
     parent::boot();
     static::created(function ($user) {
         $user->settings()->save(new Settings());
     });
 }
 public static function boot()
 {
     parent::boot();
     static::creating(function ($user) {
         $user->token = str_random(30);
     });
 }
Example #13
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $instrumentos = Instrumento::with('tags')->ofNOmbre($request->nombre)->ofTags($request->tags)->ofPrestamo($request->prestamo)->ofEstado($request->estado)->paginate(12);
     $tags = Tag::lists('nombre', 'id');
     $usuarios = array_add(User::lists('name', 'id'), '', '');
     return view('instrumentos.index', compact('instrumentos', 'tags', 'usuarios'));
 }
Example #14
0
 /**
  * @param array $options
  * @return bool
  */
 public function save(array $options = array())
 {
     $this->attributes['full_name'] = $this->attributes['first_name'] . ' ' . $this->attributes['last_name'];
     if (!array_key_exists('avatar', $this->attributes)) {
         $this->attributes['avatar'] = 'uploads/avatars/default.png';
     }
     return parent::save($options);
 }
Example #15
0
 protected static function boot()
 {
     parent::boot();
     User::creating(function ($user) {
         $user->verify_code = md5(str_random(64) . time() * 64);
         $user->types = $user->types ? $user->types : 'member';
     });
 }
Example #16
0
 public static function boot()
 {
     parent::boot();
     // Attach event handler, on deleting of the user
     User::deleting(function ($user) {
         $user->abilities()->sync([]);
     });
 }
Example #17
0
 public static function create(array $attributes = [])
 {
     $user = parent::create($attributes);
     if (array_key_exists('avatar', $attributes)) {
         self::saveAvatar($attributes['avatar'], $user);
     }
     return $user;
 }
Example #18
0
 public function sendMail()
 {
     $user = User::find(2);
     $investor = Investor::find(10);
     Mail::send('emails.reminder', ['user' => $user, 'investor' => $investor], function ($m) use($user) {
         $m->from('*****@*****.**', 'Cars2Let Investor Reporting');
         $m->to('*****@*****.**', $user->name)->subject('Your Reminder!');
     });
 }
Example #19
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //        Model::unguard();
     //
     //        $this->call(UserTableSeeder::class);
     //
     //        Model::reguard();
     User::create(['name' => 'Darwin Salinas', 'email' => '*****@*****.**', 'password' => bcrypt('admin')]);
 }
Example #20
0
 public static function boot()
 {
     parent::boot();
     User::deleting(function ($user) {
         foreach ($user->stations as $station) {
             $station->delete();
         }
     });
 }
Example #21
0
 public function can($ability, $arguments = [])
 {
     foreach ($this->individualPermissions as $permission) {
         if ($permission->name == $ability) {
             return true;
         }
     }
     return parent::can($ability, $arguments);
 }
Example #22
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //
     $faker = Faker\Factory::create();
     $users = User::lists('id')->toarray();
     $videos = User::lists('id')->toarray();
     foreach (range(1, 20) as $index) {
         Comment::create(['user_id' => $faker->randomElement($users), 'video_id' => $faker->randomElement($videos), 'comment' => $faker->sentence(), 'vote' => $faker->sentence()]);
     }
 }
 private function leftMenuCounts()
 {
     view()->composer('dashboard._partials.left.menu_bar', function ($view) {
         $view->with('usersCount', User::count());
         $view->with('categoriesCount', Category::count());
         $view->with('venuesCount', Venue::count());
         $view->with('spacesCount', Space::count());
         $view->with('amenitiesCount', Tag::where('type', 'amenity')->count());
     });
 }
Example #24
0
 /**
  * Initialiaze page modal.
  *
  * @param $name
  */
 public function __construct()
 {
     parent::__construct();
     $config = config($this->config);
     foreach ($config as $key => $val) {
         if (property_exists(get_called_class(), $key)) {
             $this->{$key} = $val;
         }
     }
 }
Example #25
0
 public static function boot()
 {
     parent::boot();
     static::saving(function (User $user) {
         $attrs = $user->getDirty();
         if (isset($attrs['password'])) {
             $user->attributes['password'] = bcrypt($user->attributes['password']);
         }
     });
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     \Illuminate\Database\Eloquent\Model::unguard();
     \Illuminate\Support\Facades\DB::table('users')->delete();
     $users = array(['name' => 'Naveed', 'email' => 'n@g.c', 'password' => \Illuminate\Support\Facades\Hash::make('naveed'), 'role' => 'Admin', 'status' => 'Enabled']);
     // Loop through each user above and create the record for them in the database
     foreach ($users as $user) {
         \Illuminate\Foundation\Auth\User::create($user);
     }
     \Illuminate\Database\Eloquent\Model::reguard();
 }
Example #27
0
 /**
  * Boot the model.
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     static::creating(function ($user) {
         $user->token = str_random(30);
         // first created user is automatically an admin
         if (\App\User::count() == 0) {
             $user->admin = 1;
         }
     });
 }
Example #28
0
 private function _users()
 {
     $provinces = Province::all();
     foreach ($provinces as $p) {
         $faker = \Faker\Factory::create();
         $user = new User();
         $user->name = $faker->name;
         $user->province_id = $p->id;
         $user->email = $faker->email;
         $user->password = Hash::make('123456');
         $user->save();
         $license = License::where('used', 0)->first();
         $license->used = 1;
         $license->save();
         $license->user()->attach($user);
         $score = new Score();
         $score->score = rand(100, 3500);
         $score->license = $license->license;
         $score->save();
     }
 }
Example #29
0
 /**
  * Bootstrap application services for user.
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     // Set token for email address verification
     // if user is not registered via social provider.
     static::creating(function ($user) {
         if ($user->is_verified) {
             return;
         }
         $user->token = str_random(30);
     });
 }
Example #30
0
 protected static function boot()
 {
     parent::boot();
     static::deleting(function ($item) {
         // before delete() method call this
         foreach ($item->contribuyentes as $emp) {
             $emp->delete();
         }
         foreach ($item->notificaciones as $emp) {
             $emp->delete();
         }
         // do the rest of the cleanup...
     });
 }