/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(CreateUserRequest $request) { $id = Auth::user()->id; if ($request->file('photo')) { $file = $request->file('photo'); $name = 'Appmm_' . time() . '.' . $file->getClientOriginalExtension(); // $path = public_path().'/upload/users/'; // $file->move($path,$name); Storage::disk('users')->put($name, \File::get($file)); } $users = new User($request->all()); $users->iduser_create = $id; $users->photo = $name; $users->save(); $profiles = new Profile(); $profiles->user_id = $users->id; $profiles->save(); Session::flash('message', 'El usuario ' . $users->name . ' Fue creado exitosamente'); //guarda el valor de los campos enviados desde el form en un array $data = $request->all(); //se envia el array y la vista lo recibe en llaves individuales {{ $email }} , {{ $subject }}... \Mail::send('emails.message', $data, function ($message) use($request) { //remitente $message->from($request->email, $request->name); //asunto $message->subject($request->name); //receptor $message->to(env('CONTACT_MAIL'), env('CONTACT_NAME')); }); return redirect()->route('admin.usuarios.index'); }
public function store(Request $request) { //dd($request); try { if (!($user = JWTAuth::parseToken()->authenticate())) { return response()->json(['user_not_found'], 404); } } catch (Tymon\JWTAuth\Exceptions\TokenExpiredException $e) { return response()->json(['token_expired'], $e->getStatusCode()); } catch (Tymon\JWTAuth\Exceptions\TokenInvalidException $e) { return response()->json(['token_invalid'], $e->getStatusCode()); } catch (Tymon\JWTAuth\Exceptions\JWTException $e) { return response()->json(['token_absent'], $e->getStatusCode()); } // the token is valid and we have found the user //dd($request->all()); try { $id = $user->profile->user_id; return response()->json(['Profile already exists'], 409); } catch (\Exception $e) { $profile = new Profile(); $profile->user_id = $user->id; $profile->name = $request->input('name'); $profile->phone_no = $request->input('phone_no'); $profile->birthdate = $request->input('birthdate'); $profile->experience = $request->input('experience'); $profile->industry_id = $request->input('spec_id'); $profile->save(); //return response()->json($profile->id); return response()->json(['success profile' . $profile->id], 200); } }
public function postAdd(UserRequest $request) { if ($request->sltRole > 2) { return redirect()->back()->with('danger', 'Dont try to be a hacker!!!'); } $model = new User(); $model->email = $request->txtEmail; $model->password = Hash::make($request->txtPass); $model->name = $request->txtName; $model->role_id = $request->sltRole; $model->level_id = $request->rdbLevel; $model->phone = $request->txtPhone; $model->birthday = $request->txtBirth; $model->department_id = $request->sltDepartment; $model->save(); $profile = new Profile(); $profile->user_id = $model->id; if ($profile->save()) { $data = ['name' => Request::input('txtName'), 'password' => Request::input('txtPass'), 'email' => Request::input('txtEmail')]; Mail::send('emails.blanks', $data, function ($message) { $message->from('*****@*****.**', 'Nguyen Trong Tri'); $message->to(Request::input('txtEmail'), Request::input('txtName'))->subject('This is mail'); }); } return redirect()->route('admin.index')->with('success', 'Added completely!'); }
public function createDefaultUserProfile(User $new_user) { $profile = new Profile(); $profile->user_id = $new_user->id; $profile->about_me = ''; $profile->profile_image_name = UserController::getDefaultImageName(); $profile->save(); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(ProfileCreateRequest $request) { $profile = new Profile(['nombre' => $request['nombre'], 'apP' => $request['apP'], 'apM' => $request['apM'], 'telefono' => $request['telefono'], 'fechaNac' => $request['telefono'], 'user_id' => $request['id']]); $profile->save(); $user = User::find($request['id']); Session::flash('message', 'Datos ingresados Correctamente'); return view('profileUsr.profile', compact('user', 'profile')); }
public function getInsert() { //インスタンス生成 $profile = new Profile(); $profile->name = "fujimon"; $profile->age = 23; $profile->detail = "ikemen"; //保存 $profile->save(); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(User $user, Request $request) { $data = $request->only('name', 'email', 'siteTitle'); $profile = new Profile(); $profile->user_id = $user->id; $profile->name = $data['name']; $profile->email = $data['email']; $profile->siteTitle = $data['siteTitle']; $profile->save(); return $profile; }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $profile = new Profile(); $profile->name = $request->input('name'); $profile->avatar = $request->input('avatar'); $profile->color = $request->input('color'); // TODO logged in user $profile->user_id = 1; $profile->save(); return response()->json(['profile' => $profile]); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $profile = new Profile(); $profile->user_id = Auth::user()->id; $profile->name = $request->input('name'); $profile->phone_no = $request->input('phone_no'); $profile->birthdate = $request->input('birthdate'); $profile->experience = $request->input('experience'); $profile->industry_id = $request->input('specialization'); $profile->save(); return view('employees.index', compact('profile')); }
public function confirm($token) { $confirm = ConfirmUser::where('token', $token)->firstOrFail(); $user = User::where('email', $confirm->email)->first(); $user->attachRole(3); $user->status = 1; $user->save(); $profile = new Profile(); $profile->user_id = $user->id; $profile->city_id = $confirm->city_id; $profile->save(); $confirm->delete(); return redirect('auth/login')->with('status', 'Вы успешно потдвердили регистрацию. Теперь войдите в систему используя свой email и пароль.'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(StoreProfileRequest $request) { $profile = new Profile(); $phone = "+" . $request->phone; $id = Auth::user()->id; $profile->user_id = $id; $profile->first_name = $request->first_name; $profile->last_name = $request->last_name; $profile->job = $request->job; $profile->phone = $phone; $profile->location = $request->location; $profile->motto = $request->motto; $profile->about = $request->about; $profile->save(); return redirect()->route('suite')->with('info', 'You have completed your profile!'); }
/** * Store a newly created resource in storage. * * @param int $iid industry_id * @param Request $request * @return Response */ public function store($iid, Request $request) { $industry = Industry::findOrFail($iid); $profile = new Profile(); $profile->name = $request->input('name'); $profile->phone_no = $request->input('phone_no'); $profile->birthdate = $request->input('birthdate'); $profile->experience = $request->input('experience'); $profile->industry_id = $iid; $profile->save(); //$input = $request->all(); //$input['industry_id'] = $iid; //Profile::create($input); //return redirect('industries.profiles.show', compact('industry')); return view('profiles.index', compact('industry')); }
public function confirm($token) { $confirm = ConfirmUser::where('token', $token)->firstOrFail(); $user = User::where('email', $confirm->email)->first(); $user->attachRole(3); $user->status = 1; $user->save(); $profile = new Profile(); $profile->user_id = $user->id; $profile->city_id = $confirm->city_id; $contacts = ['phone' => null, 'telegram' => null, 'whatsapp' => null, 'viber' => null, 'phone2' => null, 'telegram2' => null, 'whatsapp2' => null, 'viber2' => null]; $profile->phone = json_encode($contacts); $profile->save(); $confirm->delete(); return redirect('auth/login')->with('status', 'Вы успешно потдвердили регистрацию. Теперь войдите в систему используя свой email и пароль.'); }
public function create() { $user = Auth::user(); // try to find the profile id that matches the user profile try { $profile = Profile::where('user_id', $user->id)->firstOrFail(); } catch (ModelNotFoundException $e) { // if it fails create profile $profile = new Profile(); $profile->user_id = $user->id; $profile->save(); flash()->overlay('Welcome to Baking Amigo!', 'Now tell us a bit about yourself.', 'info'); } // redirect to the edit page return redirect("/users/{$user->id}/edit"); }
public function uploadTn($fileName, $image) { $path = public_path('/images/' . Auth::user()->name); File::exists($path) or File::makeDirectory($path, 0755, true); $image->save($path . '/' . $fileName)->resize(128, 128)->save($path . '/' . 'pp.jpg'); if (Auth::user()->profile == null) { $picture = new Profile(); $picture->user_id = Auth::user()->id; $picture->thumbnailName = 'images/' . Auth::user()->name . '/pp.jpg'; $picture->save(); } else { $picture = Profile::where('user_id', Auth::user()->id)->first(); $picture->user_id = Auth::user()->id; $picture->thumbnailName = 'images/' . Auth::user()->name . '/pp.jpg'; $picture->save(); } }
public function addUserPost() { $profile = Profile::where('no_gaji', Request::get('no_gaji'))->first(); if (!empty($profile)) { Session::flash('error', 'Gagal. No gaji *' . Request::get('no_gaji') . '* bertindih.'); return Redirect::back()->withInput(); } $no_anggota = Profile::where('no_anggota', Request::get('no_anggota'))->first(); if (!empty($no_anggota)) { Session::flash('error', 'Gagal. No anggota *' . Request::get('no_anggota') . '* bertindih.'); return Redirect::back()->withInput(); } $nokp = Profile::where('nokp', Request::get('nokp'))->first(); if (!empty($nokp)) { Session::flash('error', 'Gagal. No KP *' . Request::get('nokp') . '* telah wujud, dengan No Gaji *' . $nokp->no_gaji . '*.'); return Redirect::back()->withInput(); } $validation = Validator::make(Request::all(), ['no_anggota' => 'required|numeric', 'no_gaji' => 'required|numeric', 'profile_category_id' => 'required|numeric', 'nama' => 'required', 'nokp' => 'required', 'jantina_id' => 'required', 'bangsa' => 'required', 'jumlah_yuran_bulanan' => 'required|numeric', 'zon_gaji_id' => 'required|numeric']); if ($validation->fails()) { Session::flash('error', 'Sila isikan ruangan dengan format yang betul'); return Redirect::back()->withInput()->withErrors($validation); } $profile = new Profile(); $profile->fill(Request::all()); $profile->jumlah_yuran_bulanan = Request::get('jumlah_yuran_bulanan'); $profile->nama = strtoupper(Request::get('nama')); $profile->tarikh_ahli = Carbon::now(); $profile->jantina_id = Request::get('jantina_id'); $profile->alamat1 = strtoupper(Request::get('alamat1')); $profile->alamat2 = strtoupper(Request::get('alamat2')); $profile->jawatan = strtoupper(Request::get('jawatan')); $profile->email = strtoupper(Request::get('email')); $profile->taraf_jawatan = strtoupper(Request::get('taraf_jawatan')); if ($profile->save()) { Session::flash('success', 'Berjaya. Anggota baru telah didaftarkan'); } else { Session::flash('error', 'Gagal. Anggota baru gagal didaftarkan'); } return Redirect::route('members.profiles.addUser'); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(UserRequest $request, User $user) { // $model = new User(); $model->email = $request->txtEmail; $model->password = Hash::make($request->txtPass); $model->name = $request->txtName; $model->role_id = $request->sltRole; $model->level_id = $request->rdbLevel; $model->phone = $request->txtPhone; $model->birthday = $request->txtBirth; $model->department_id = $request->sltDepartment; $model->save(); $profile = new Profile(); $profile->user_id = $model->id; $profile->save(); Mail::send('emails.blanks', ['email' => $request->txtEmail, 'password' => $request->txtPass], function ($message) { $message->from('*****@*****.**', 'Nguyen Trong Tri'); $message->to($request->txtEmail, $request->txtName)->subject('This is mail'); }); return redirect()->route('admin.staff.index')->with('success', 'Posted completely!'); }
public function postRegister(Request $request) { $input = $request->all(); $email = $input['email']; $password = $input['password']; if (User::where('email', $email)->first()) { return view('register')->with('registerError', ['Email has been registered']); } try { $user = new User($input); $user->password = password_hash($password, PASSWORD_BCRYPT); $user->save(); // Creating empty profile on registration saves a lot of sanity checking $profile = new Profile(); $profile->user_id = $user->id; $profile->save(); Auth::login($user); return redirect()->action('CmsController@index'); } catch (Exception $e) { return view('erros.503'); } }
/** * save profile * * @param Profile $profile * * @return [type] */ public function saveProfile(Profile $profile) { $profile->save(); }
/** * @return bool * * Track all round record into Database. */ public function track() { /** * @var Game */ $game = new Game(); $game->tag = $this->roundTag; $game->server_time = $this->serverTime; $game->round_time = $this->timePlayed; $game->round_index = $this->roundIndex + 1 . " / " . $this->roundLimit; $game->gametype = $this->gameType; $game->outcome = $this->roundOutcome; $game->map_id = $this->gameMap; $game->total_players = $this->totalPlayers; $game->swat_score = $this->swatScore; $game->suspects_score = $this->suspectsScore; $game->swat_vict = $this->swatVictory; $game->suspects_vict = $this->suspectsVictory; if (!$game->save()) { return false; } /** * Iterate over each player array */ foreach ($this->players as $p) { /** * @var Player */ $player = new Player(); $player->ingame_id = $p[0]; $player->ip_address = $p[1]; $player->name = str_replace('(VIEW)', '', $p[5]); $player->name = str_replace('(SPEC)', '', $player->name); $player->team = array_key_exists(6, $p) ? $p[6] : 0; $player->is_admin = array_key_exists(3, $p) ? $p[3] : 0; $player->is_dropped = array_key_exists(2, $p) ? $p[2] : 0; $player->score = array_key_exists(8, $p) ? $p[8] : 0; $player->time_played = array_key_exists(7, $p) ? $p[7] : 0; $player->kills = array_key_exists(9, $p) ? $p[9] : 0; $player->team_kills = array_key_exists(10, $p) ? $p[10] : 0; $player->deaths = array_key_exists(11, $p) ? $p[11] : 0; $player->suicides = array_key_exists(12, $p) ? $p[12] : 0; $player->arrests = array_key_exists(13, $p) ? $p[13] : 0; $player->arrested = array_key_exists(14, $p) ? $p[14] : 0; $player->kill_streak = array_key_exists(15, $p) ? $p[15] : 0; $player->arrest_streak = array_key_exists(16, $p) ? $p[16] : 0; $player->death_streak = array_key_exists(17, $p) ? $p[17] : 0; $player->game_id = $game->id; $player_ip_trim = substr($p[1], 0, strrpos($p[1], ".")); $player_country_id = 0; $geoip = App::make('geoip'); try { if ($player_geoip = $geoip->city($player->ip_address)) { $player_isoCode = $player_geoip->country->isoCode; $country = Country::where('countryCode', 'LIKE', $player_isoCode)->first(); /** * Country returned is not in Countrie table */ if ($country == null) { $player_country_id = 0; } else { $player_country_id = $country->id; } } } catch (\Exception $e) { switch ($e) { case $e instanceof \InvalidArgumentException: $player_country_id = 0; break; case $e instanceof \GeoIp2\Exception\AddressNotFoundException: $player_country_id = 0; break; default: $player_country_id = 0; break; } } $loadout_array = array_key_exists(39, $p) ? $p[39] : [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; /** * @var Loadout * * Create or find and return instance of Loadout and save to database. */ $loadout = Loadout::firstOrCreate(['primary_weapon' => array_key_exists(0, $loadout_array) ? $loadout_array[0] : 0, 'primary_ammo' => array_key_exists(1, $loadout_array) ? $loadout_array[1] : 0, 'secondary_weapon' => array_key_exists(2, $loadout_array) ? $loadout_array[2] : 0, 'secondary_ammo' => array_key_exists(3, $loadout_array) ? $loadout_array[3] : 0, 'equip_one' => array_key_exists(4, $loadout_array) ? $loadout_array[4] : 0, 'equip_two' => array_key_exists(5, $loadout_array) ? $loadout_array[5] : 0, 'equip_three' => array_key_exists(6, $loadout_array) ? $loadout_array[6] : 0, 'equip_four' => array_key_exists(7, $loadout_array) ? $loadout_array[7] : 0, 'equip_five' => array_key_exists(8, $loadout_array) ? $loadout_array[8] : 0, 'breacher' => array_key_exists(9, $loadout_array) ? $loadout_array[9] : 0, 'body' => array_key_exists(10, $loadout_array) ? $loadout_array[10] : 0, 'head' => array_key_exists(11, $loadout_array) ? $loadout_array[11] : 0]); /** * Create or find and return instance of Alias. */ $alias = Alias::firstOrNew(['name' => $player->name]); /** * If Alias is not present then new instance is created. */ if ($alias->id == null) { //$profile = Profile::firstOrNew(['ip_address' => $player_ip_trim.'%']); $profile = Profile::where('ip_address', 'LIKE', $player_ip_trim . '%')->first(); // If no profile present create new else ignore. if (!$profile) { $profile = new Profile(); } /** * Neither Alias not Profile is present. * * So it will create both new Alias and Profile. */ if ($profile->id == null) { $profile->name = $player->name; $profile->team = $player->team; $profile->country_id = $player_country_id; $profile->loadout_id = $loadout->id; $profile->game_first = $game->id; $profile->game_last = $game->id; $profile->ip_address = $player->ip_address; $profile->save(); $alias->name = $player->name; $alias->profile_id = $profile->id; $alias->ip_address = $player->ip_address; $alias->save(); } else { $alias->name = $player->name; $alias->profile_id = $profile->id; $alias->ip_address = $player->ip_address; $alias->save(); $profile->team = $player->team; $profile->game_last = $game->id; $profile->loadout_id = $loadout->id; $profile->ip_address = $player->ip_address; $profile->country_id = $player_country_id; $profile->save(); } } else { $profile = Profile::find($alias->profile_id); $profile->team = $player->team; $profile->game_last = $game->id; $profile->loadout_id = $loadout->id; $profile->ip_address = $player->ip_address; $profile->country_id = $player_country_id; $profile->save(); $alias->ip_address = $player->ip_address; $alias->save(); } $player->alias_id = $alias->id; $player->loadout_id = $loadout->id; $player->country_id = $player_country_id; $player->save(); /** * Iterate over all Weapon of each Player if exists */ if (array_key_exists(40, $p)) { foreach ($p[40] as $w) { $weapon = new Weapon(); $weapon->name = $w[0]; $weapon->player_id = $player->id; $weapon->seconds_used = array_key_exists(1, $w) ? $w[1] : 0; $weapon->shots_fired = array_key_exists(2, $w) ? $w[2] : 0; $weapon->shots_hit = array_key_exists(3, $w) ? $w[3] : 0; $weapon->shots_teamhit = array_key_exists(4, $w) ? $w[4] : 0; $weapon->kills = array_key_exists(5, $w) ? $w[5] : 0; $weapon->teamkills = array_key_exists(6, $w) ? $w[6] : 0; $weapon->distance = array_key_exists(7, $w) ? $w[7] : 0; $weapon->save(); } } } //$pt = new App\Server\Repositories\PlayerTotalRepository(); //$pt->calculate(); //$response = Response::make("0\\nStats has been successfully tracked",200); printf("%s", "0\nRound report tracked."); exit(0); }
public function postProfile(Request $request) { $user_id = Auth::User()->id; $profile = new Profile(); $profile->user_id = $user_id; $profile->company_name = $request->company_name; $profile->contact_name = $request->contact_name; $profile->email = $request->email; $profile->phone = $request->phone; $profile->postal_code = $request->postal_code; $profile->address_one = $request->address_one; $profile->address_two = $request->address_two; $profile->city = $request->city; $profile->state = $request->state; $profile->country_id = $request->country_id; $profile->about = $request->about; $profile->status = 1; $profile->visibility = 1; if ($profile->save()) { redirect::to('agent/profile'); } }
public function store($input) { $profile = new Profile(); $profile->name = $input['name']; return $profile->save(); }
public function postUserRegister(UserRegisterRequest $request, User $user) { $user->fill($request->all()); $user->password = bcrypt($request->input('password')); $key = config('app.key'); $confirmation_code = hash_hmac('sha256', str_random(40), $key); $user->confirmation_code = $confirmation_code; $user->save(); Mail::send('emails.activate', ['token' => $confirmation_code, 'name' => $user->name], function ($message) use($user) { $message->to($user->getEmailForPasswordReset(), $user->name)->subject('Activate your account'); }); $profile = new Profile(); $profile->user()->associate($user); $profile->save(); $role = Role::where('name', '=', 'user')->first(); if ($role) { $user->attachRole($role->id); } return redirect('/')->withSuccess('User registered successfully.'); }
/** * Update the access token on the profile. * * @param \App\Profile $profile * @param string $token * * @return \App\Profile */ public function updateToken(Profile $profile, $token) { $profile->access_token = $token; $profile->save(); return $profile; }
/** * Create a new event instance. * * @return void */ public function __construct($EcNa, $typ, $eml, $pass, $nomresp, $fix, $port, $adres, $ville, $pays, $typeCompte, $sexe) { $this->ecoleNom = $EcNa; $this->type = $typ; $this->email = $eml; $this->password = $pass; $this->nomResponsable = $nomresp; $this->fix = $fix; $this->portab = $port; $this->adresse = $adres; $this->ville = $ville; $this->pays = $pays; $this->typeCompte = $typeCompte; $this->sexe = $sexe; $user = new User(); $user->name = $this->ecoleNom; $user->type = $this->type; $user->email = $this->email; $user->password = \Hash::make($this->password); $user->nom_responsable = $this->nomResponsable; $user->tel_fixe = $this->fix; $user->tel_portable = $this->portab; $user->adresse = $this->adresse; $user->ville = $this->ville; $user->pays = $this->pays; $user->typeCompte = $this->typeCompte; $user->sexe = $this->sexe; $user->save(); $profile = Profile::where('user_id', $user->id)->first(); if (!$profile) { $pr = new Profile(); $pr->user_id = $user->id; $pr->save(); } if ($user) { $info = ['nom_resp' => $this->nomResponsable, 'sexe' => $this->sexe, 'nom_ecole' => $this->ecoleNom, 'email' => $this->email, 'pass' => $this->password, 'date' => $user->created_at]; Mail::send('emails.school', $info, function ($message) { $message->to($this->email, 'ok')->from('*****@*****.**')->subject('Bienvenue !'); }); } /*else { $user->save(); // sending email $info = [ 'nom_resp' => $this->nomResponsable, 'sexe' => $this->sexe, 'nom_ecole' =>$this->ecoleNom, 'email' => $this->email, 'pass' => $this->password, 'date' =>$user->created_at ]; Mail::send('emails.school',$info,function($message){ $message->to($this->email,'ok')->from('*****@*****.**')->subject('Bienvenue !'); }); // Sending Email for ($i = 1; $i <= 4; $i++) { $cb = new CategoryBill(); $cb->name = $i; switch ($i) { case $i == 1: $cb->age_de = 0; $cb->age_a = 5; $cb->prix = 200; $cb->user_id = $user->id; $cb->save(); break; case $i == 2: $cb->age_de = 6; $cb->age_a = 10; $cb->prix = 300; $cb->user_id = $user->id; $cb->save(); break; case $i == 3: $cb->age_de = 11; $cb->age_a = 15; $cb->prix = 400; $cb->user_id = $user->id; $cb->save(); break; case $i == 4: $cb->age_de = 16; $cb->age_a = 20; $cb->prix = 500; $cb->user_id = $user->id; $cb->save(); break; } } //end for CategoryBill Model $tr = new Transport(); $tr->somme = 200; $tr->user_id = $user->id; $tr->save(); for ($i = 1; $i <= 2; $i++) { $lv = new Level(); $lv->niveau = ($i == 1)? 'première année bac' :'deuxième année bac'; $lv->user_id = $user->id; $lv->save(); } //salles for ($i = 1; $i <= 2; $i++) { $room = new Room(); $room->nom_salle = 'salle '.$i; $room->capacite_salle = 30; $room->user_id = $user->id; $room->color = 'black'; $room->save(); } // matieres for ($i = 1; $i <= 4; $i++) { switch($i) { case $i == 1: $matter = new Matter(); $matter->nom_matiere ='Francais'; $matter->code_matiere = 'Fr'; $matter->color = 'blue'; $matter->user_id = $user->id; $matter->save(); //teacher $teacher = new Teacher(); $teacher->nom_teacher = 'Iliass omar'; $teacher->date_naissance = '1980-11-11'; $teacher->poste = Matter::where('user_id',$user->id)->where('code_matiere','Fr')->first()->nom_matiere; $teacher->fonction = 'Professeur'; $teacher->sexe = 'Homme'; $teacher->email = 'NoEmail-'.str_random(4).'@gmail.com'; $teacher->num_fix = '0212444578'; $teacher->num_portable = '0666145847'; $teacher->adresse = 'No Adresse for the moment'; $teacher->cin = str_random(6); $teacher->salaire = 5000; $teacher->user_id = $user->id; $teacher->save(); if($teacher) { $teacher->matters()->attach([$matter->id]); }; break; case $i == 2: $matter = new Matter(); $matter->nom_matiere ='Math'; $matter->code_matiere = 'Mt'; $matter->color = '#e2641b'; $matter->user_id = $user->id; $matter->save(); //teacher $teacher = new Teacher(); $teacher->nom_teacher = 'anass fouad'; $teacher->date_naissance = '1980-11-11'; $teacher->poste = Matter::where('user_id',$user->id)->where('code_matiere','Mt')->first()->nom_matiere; $teacher->fonction = 'Professeur'; $teacher->sexe = 'Homme'; $teacher->email = 'NoEmail-'.str_random(4).'@gmail.com'; $teacher->num_fix = '0212444578'; $teacher->num_portable = '0666145847'; $teacher->adresse = 'No Adresse for the moment'; $teacher->cin = str_random(6); $teacher->salaire = 5000; $teacher->user_id = $user->id; $teacher->save(); if($teacher) { $teacher->matters()->attach([$matter->id]); }; break; case $i == 3: $matter = new Matter(); $matter->nom_matiere ='Anglais'; $matter->code_matiere = 'Ang'; $matter->color = '#687B8C'; $matter->user_id = $user->id; $matter->save(); //teacher $teacher = new Teacher(); $teacher->nom_teacher = 'Wael belekbir'; $teacher->date_naissance = '1980-11-11'; $teacher->poste = Matter::where('user_id',$user->id)->where('code_matiere','Ang')->first()->nom_matiere; $teacher->fonction = 'Professeur'; $teacher->sexe = 'Homme'; $teacher->email = 'NoEmail-'.str_random(4).'@gmail.com'; $teacher->num_fix = '0212444578'; $teacher->num_portable = '0666145847'; $teacher->adresse = 'No Adresse for the moment'; $teacher->cin = str_random(6); $teacher->salaire = 5000; $teacher->user_id = $user->id; $teacher->save(); if($teacher) { $teacher->matters()->attach([$matter->id]); }; break; case $i == 4: $matter = new Matter(); $matter->nom_matiere ='Histoire'; $matter->code_matiere = 'Hst'; $matter->color = '#7F64B5'; $matter->user_id = $user->id; $matter->save(); //teacher $teacher = new Teacher(); $teacher->nom_teacher = 'Achraf el fouhami'; $teacher->date_naissance = '1980-11-11'; $teacher->poste = Matter::where('user_id',$user->id)->where('code_matiere','Hst')->first()->nom_matiere; $teacher->fonction = 'professeur'; $teacher->sexe = 'Homme'; $teacher->email = 'NoEmail-'.str_random(4).'@gmail.com'; $teacher->num_fix = '0212444578'; $teacher->num_portable = '0666145847'; $teacher->adresse = 'No Adresse for the moment'; $teacher->cin = str_random(6); $teacher->salaire = 5000; $teacher->user_id = $user->id; $teacher->save(); if($teacher) { $teacher->matters()->attach([$matter->id]); }; break; } } // classrooms for ($i = 1; $i <= 2; $i++) { $cr = new Classroom(); $cr->nom_classe = 'classe '.$i; $cr->code_classe = 'cl'.$i; $cr->capacite_classe = 30; $cr->niveau = ($i == 1 ) ?'première année bac' : 'Deuxième année bac'; $cr->branche = ($i == 1) ? 'Littéraire' : 'Sciences'; $cr->user_id = $user->id; $cr->save(); if($cr) { $classe = Classroom::where('user_id',$user->id)->where('code_classe','cl'.$i)->first(); if($i == 1) { $classe->matters()->attach([Matter::where('user_id',$user->id)->where('code_matiere','Fr')->first()->id]); }else{ $classe->matters()->attach([Matter::where('user_id',$user->id)->where('code_matiere','Ang')->first()->id]); } } $ts = new Timesheet(); $ts->user_id = $user->id; $ts->classroom_id = $cr->id; $ts->save(); } // branches for ($i = 1; $i <= 2; $i++) { $br = new Branch(); $br->nom_branche = ($i == 1 ) ? 'Littéraire': 'Sciences'; $br->code_branche = ($i == 1) ? 'LT': 'Sc'; $br->user_id = $user->id; $br->save(); } $peres = ['Yassine bennani', 'Kamal El alami', 'Fouad taqi', 'Omar el mesoudi']; $meres = ['Fatine nour', 'imane safi', 'widad fathi', 'yasmine amara']; $eleves = ['walid bennani', 'wael El alami', 'achraf taqi', 'nassim el mesoudi']; $adress = [ '14 Kildeer Avenue PARIS FRANCE', '147 Lightning Street LONDON UK', '164 Reel Place DORTMUND GERMANY', '875 Clark Lake SIDNEY AUSTRALIA' ]; $phonesp = ['0214125124', '0215452214', '0218445144', '03412541254']; $phonesf = ['01454545554', '02315454545', '0645412151', '0214541145']; $cin = ['ab114477', 'an475965', 'nb112354', 'ui786519']; $dates = ['2000-02-02', '2005-02-01', '2010-02-03', '2014-01-05']; $sexe = ['Garçon', 'fille']; for ($i = 0; $i <= 3; $i++) { switch ($i) { case $i == 0: $family = new Family(); $family->nom_pere = $peres[$i]; $family->nom_mere = $meres[$i]; $family->email_responsable = 'NoEmailinEssaiAccount-' .str_random(4).$i.str_random(2).'@gmail.com'; $family->adresse = $adress[$i]; $family->numero_fixe = $phonesf[$i]; $family->numero_portable = $phonesp[$i]; $family->cin = strtoupper(str_random(6)); $family->responsable = 1; $family->user_id = $user->id; $family->save(); // compte famille user $f = new User(); $f->nom_responsable = $family->nom_pere; $f->name = $user->name; $f->type = 'famille'; $f->email = $family->email_responsable; $f->password = \Hash::make('123456'); $f->sexe = 'homme'; $f->save(); if ($family->id) { $child = new Child(); $child->date_naissance = Carbon::parse($dates[$i]); $child->transport = 0; $child->sexe = $sexe[0]; $child->nom_enfant = ucfirst($eleves[$i]); $child->age_enfant = $child->date_naissance->diffInYears(Carbon::now()); $child->user_id = $user->id; $child->photo = ''; $child->family_id = $family->id; $child->save(); if ($child->id) { //classe $cr = Classroom::where('user_id',$user->id)->where('code_classe', 'cl1')->first(); $cr->children()->attach([$child->id]); $bill = new Bill(); $bill->start = Carbon::now()->toDateString(); $bill->end = Carbon::now()->addMonth()->toDateString(); $bill->status = 0; $bill->somme = CategoryBill::getYearFoEssai($user,Carbon::parse($child->date_naissance)); $bill->child_id = $child->id; $bill->user_id = $user->id; $bill->save(); if($f) { $enf = Child::findOrFail($child->id); $enf->f_id =$f->id; $enf->save(); $b = Bill::where('child_id',$enf->id)->first(); $b->f_id = $f->id; $b->save(); } } }; break; case $i == 1: $family = new Family(); $family->nom_pere = $peres[$i]; $family->nom_mere = $meres[$i]; $family->email_responsable = 'NoEmailinEssaiAccount-' .str_random(4).$i.str_random(2).'@gmail.com'; $family->adresse = $adress[$i]; $family->numero_fixe = $phonesf[$i]; $family->numero_portable = $phonesp[$i]; $family->cin = strtoupper(str_random(6)); $family->responsable = 1; $family->user_id = $user->id; $family->save(); // compte famille user $f = new User(); $f->nom_responsable = $family->nom_pere; $f->name = $user->name; $f->type = 'famille'; $f->email = $family->email_responsable; $f->password = \Hash::make('123456'); $f->sexe = 'homme'; $f->save(); if ($family->id) { $child = new Child(); $child->date_naissance = Carbon::parse($dates[$i]); $child->transport = 0; $child->sexe = $sexe[0]; $child->nom_enfant = ucfirst($eleves[$i]); $child->age_enfant = $child->date_naissance->diffInYears(Carbon::now()); $child->user_id = $user->id; $child->photo = ''; $child->family_id = $family->id; $child->save(); if ($child->id) { //classe $cr = Classroom::where('user_id',$user->id)->where('code_classe','cl1')->first(); $cr->children()->attach([$child->id]); $bill = new Bill(); $bill->start = Carbon::now()->toDateString(); $bill->end = Carbon::now()->addMonth()->toDateString(); $bill->status = 0; $bill->somme = CategoryBill::getYearFoEssai($user,Carbon::parse($child->date_naissance)); $bill->child_id = $child->id; $bill->user_id = $user->id; $bill->save(); if($f) { $enf = Child::findOrFail($child->id); $enf->f_id =$f->id; $enf->save(); $b = Bill::where('child_id',$enf->id)->first(); $b->f_id = $f->id; $b->save(); } } }; break; case $i == 2: $family = new Family(); $family->nom_pere = $peres[$i]; $family->nom_mere = $meres[$i]; $family->email_responsable = 'NoEmailinEssaiAccount-' .str_random(4).$i.str_random(2).'@gmail.com'; $family->adresse = $adress[$i]; $family->numero_fixe = $phonesf[$i]; $family->numero_portable = $phonesp[$i]; $family->cin = strtoupper(str_random(6)); $family->responsable = 1; $family->user_id = $user->id; $family->save(); $f = new User(); $f->nom_responsable = $family->nom_pere; $f->name = $user->name; $f->type = 'famille'; $f->email = $family->email_responsable; $f->password = \Hash::make('123456'); $f->sexe = 'homme'; $f->save(); if ($family->id) { $child = new Child(); $child->date_naissance = Carbon::parse($dates[$i]); $child->transport = 0; $child->sexe = $sexe[0]; $child->nom_enfant = ucfirst($eleves[$i]); $child->age_enfant = $child->date_naissance->diffInYears(Carbon::now()); $child->user_id = $user->id; $child->photo = ''; $child->family_id = $family->id; $child->save(); if ($child->id) { //classe $cr = Classroom::where('user_id',$user->id)->where('code_classe','cl2')->first(); $cr->children()->attach([$child->id]); $bill = new Bill(); $bill->start = Carbon::now()->toDateString(); $bill->end = Carbon::now()->addMonth()->toDateString(); $bill->status = 0; $bill->somme = CategoryBill::getYearFoEssai($user,Carbon::parse($child->date_naissance)); $bill->child_id = $child->id; $bill->user_id = $user->id; $bill->save(); if($f) { $enf = Child::findOrFail($child->id); $enf->f_id =$f->id; $enf->save(); $b = Bill::where('child_id',$enf->id)->first(); $b->f_id = $f->id; $b->save(); } } }; break; case $i == 3: $family = new Family(); $family->nom_pere = $peres[$i]; $family->nom_mere = $meres[$i]; $family->email_responsable = 'NoEmailinEssaiAccount-' .str_random(4).$i.str_random(2).'@gmail.com'; $family->adresse = $adress[$i]; $family->numero_fixe = $phonesf[$i]; $family->numero_portable = $phonesp[$i]; $family->cin = strtoupper(str_random(6)); $family->responsable = 1; $family->user_id = $user->id; $family->save(); $f = new User(); $f->nom_responsable = $family->nom_pere; $f->name = $user->name; $f->type = 'famille'; $f->email = $family->email_responsable; $f->password = \Hash::make('123456'); $f->sexe = 'homme'; $f->save(); if ($family->id) { $child = new Child(); $child->date_naissance = Carbon::parse($dates[$i]); $child->transport = 0; $child->sexe = $sexe[0]; $child->nom_enfant = ucfirst($eleves[$i]); $child->age_enfant = $child->date_naissance->diffInYears(Carbon::now()); $child->user_id = $user->id; $child->photo = ''; $child->family_id = $family->id; $child->save(); if ($child->id) { //classe $cr = Classroom::where('user_id',$user->id)->where('code_classe', 'cl2')->first(); $cr->children()->attach([$child->id]); $bill = new Bill(); $bill->start = Carbon::now()->toDateString(); $bill->end = Carbon::now()->addMonth()->toDateString(); $bill->status = 0; $bill->somme = CategoryBill::getYearFoEssai($user,Carbon::parse($child->date_naissance)); $bill->child_id = $child->id; $bill->user_id = $user->id; $bill->save(); if($f) { $enf = Child::findOrFail($child->id); $enf->f_id =$f->id; $enf->save(); $b = Bill::where('child_id',$enf->id)->first(); $b->f_id = $f->id; $b->save(); } } }; break; } } } */ }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, Profile $profile, Image $img) { $this->validate($request, ['photo' => 'image|max:4000', 'gender' => 'required', 'name' => 'required|max:70', 'bio' => 'max:4500', 'phone' => 'max:50', 'education' => 'max:150', 'skills' => 'max:90', 'work' => 'max:100', 'location' => 'max:100']); $user = $profile->user; //Update the User name with the new value passed $user->name = $request->input('name'); $user->save(); // Save the image $photoPath = $this->saveImage($request, $user); $profile->update($request->all()); $profile->photo = $photoPath; $profile->save(); if ($request->ajax()) { return response()->json(['success' => 1, 'data' => $user]); } return redirect()->route('admin.profiles.index')->withSuccess("Your profile has been updated..."); }
public function twitter() { $twitter_user = \Socialize::driver('twitter')->user(); //echo $twitter_user->nickname."CCC"; //echo "<pre>"; //print_r($twitter_user); //echo "</pre>"; //exit; $name = $twitter_user->name; $email = $twitter_user->email; $u_name = preg_replace('/@.*$/', '', $email); $input['email'] = $email; $rules = array('email' => 'unique:users,email'); $validator = \Validator::make($input, $rules); $credentials = array('email' => $email, 'password' => $u_name); if ($validator->fails()) { if (\Auth::attempt($credentials)) { return redirect('/home')->with('message', 'Successfully logged in with Twitter'); } } else { // Register the new user or whatever. $user = new User(); $user->name = $name; $user->type = 'general'; $user->register_type = 'twitter'; $user->username = $u_name; $user->email = $email; $user->password = bcrypt($u_name); $user->save(); $user_obj = User::where('email', $email)->first(); $profile = new Profile(); $profile->user_id = $user_obj->id; $profile->save(); if (\Auth::attempt($credentials)) { return redirect('/home')->with('message', 'Successfully logged in with Twitter'); } } }