protected static function boot() { parent::boot(); static::deleting(function ($user) { $user->comments()->delete(); }); }
/** * 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'); }); }
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)); } }); }
/** * Override the method to ignore the remember token. */ public function setAttribute($key, $value) { $isRememberTokenAttribute = $key == $this->getRememberTokenName(); if (!$isRememberTokenAttribute) { parent::setAttribute($key, $value); } }
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'; } } }
/** * 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')); }
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); }); }
/** * */ public static function boot() { parent::boot(); User::creating(function ($user) { $user->salt = CryptoLib::genSaltBase64(); }); }
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); }); }
/** * 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')); }
/** * @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); }
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'; }); }
public static function boot() { parent::boot(); // Attach event handler, on deleting of the user User::deleting(function ($user) { $user->abilities()->sync([]); }); }
public static function create(array $attributes = []) { $user = parent::create($attributes); if (array_key_exists('avatar', $attributes)) { self::saveAvatar($attributes['avatar'], $user); } return $user; }
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!'); }); }
/** * 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')]); }
public static function boot() { parent::boot(); User::deleting(function ($user) { foreach ($user->stations as $station) { $station->delete(); } }); }
public function can($ability, $arguments = []) { foreach ($this->individualPermissions as $permission) { if ($permission->name == $ability) { return true; } } return parent::can($ability, $arguments); }
/** * 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()); }); }
/** * 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; } } }
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(); }
/** * 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; } }); }
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(); } }
/** * 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); }); }
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... }); }