public function all_clients_email() { $clients = Client::all(); $emails = []; foreach ($clients as $client) { $emails[] = $client->client_email; } return $emails; }
public function index() { $limit = 2; $announcement = Announcement::orderBy('created_at', 'desc')->limit($limit)->get(); $now = new Datetime(); $now = $now->format('Y-m-d'); $upcomingTrainings = Training::where('status', '=', 1)->where('start_date', '>', Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $now . ' 00:00:00'))->orderBy('start_date', 'asc')->limit($limit)->get(); $ongoingTrainings = Training::where('status', '=', 1)->where('start_date', '<=', Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $now . ' 00:00:00'))->where('end_date', '>=', Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $now . ' 00:00:00'))->limit($limit)->get(); $all_slider = Slider::orderBy('position', 'asc')->get(); $clients = Client::orderBy('created_at', 'desc')->limit(5)->get(); return view('bard_frontend.index', compact('announcement', 'upcomingTrainings', 'ongoingTrainings', 'all_slider', 'clients')); }
public function index() { //If the register form was sent if (Form::exists('login_form')) { //Check if User exists $user = Client::getOneBy(array('_mail' => Form::get('mail'))); //Confirm if PW matches if ($user && $user->getPassword() == Client::encryptPassword(Form::get('password'))) { Session::connect($user); return \App\Component\Redirect::to('/'); } $error = "Vos informations de connexion sont incorrects. Merci de réessayer."; return View::render("login/index.php", array('error' => $error)); } return View::render("index/index.php"); }
public function index() { //If the register form was sent if (Form::exists('register_form')) { //We check if all the input are filled if (Form::checkEmpty(array('mainAddress', 'firstName', 'mail', 'name', 'password', 'password_check', 'phoneNumber', 'birthday'))) { $error = "Veuillez remplir tous les champs"; return View::render("register/index.php", array('error' => $error)); } //We check if the mail address is not already taken if (Client::getOneBy(array('_mail' => Form::get('mail')))) { $error = "Cette adresse e-mail est déjà associée à un compte. Veuillez en choisir une autre."; return View::render("register/index.php", array('error' => $error)); } //We check if the password and the check are the same if (Form::get('password') != Form::get('password_check')) { $error = "Les mots de passe ne correspondent pas."; return View::render("register/index.php", array('error' => $error)); } //We create a new User, and associate the values $user = new Client(); $user->setFirstName(Form::get('firstName')); $user->setMail(Form::get('mail')); $user->setName(Form::get('name')); $user->setPassword(Form::get('password')); $user->setPhoneNumber(Form::get('phoneNumber')); $user->setBirthday(Form::get('birthday')); //We save this User in the DB $user->save(); $address = new \App\Model\Address(); $address->setAddress(Form::get('mainAddress')); $address->setUser($user); $address->save(); $user->setAddress($address); $user->save(); return View::render("register/complete.php", array('user' => $user)); } return View::render("register/index.php"); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $client = Client::whereId($id)->first(); unlink('uploads/' . $client->client_logo); $client->delete(); return redirect('/admin/clients'); }
private function addCommande() { $commandes = Commande::getBy(array()); $mail = true; while (count($commandes) <= 5) { $commande = new Commande(); $restaurant = Restaurant::getOneBy(array('name' => 'Ma Queue Mickey')); $item = ItemMenu::getOneBy(array('name' => 'Burger')); $address = Address::getOneBy(array('address' => '18 Rue des Roses')); $commande->setItem($item, 2); $commande->setStatus(Commande::COMMAND_STATUS_PAYED); $commande->setDatetime('12/12/12 12:12'); $commande->createConfirmationCode(); $commande->setAddress($address); $client = Client::getOneBy(array('_mail' => "*****@*****.**")); $commande->setClient($client); $commande->save(); $restaurant->save(); $commandes = Commande::getBy(array()); } }
public function C_Return($name, $movieName) { $client = new Client(); $movie = new DVD(); $time = new DateTime(); $clientData = $client->getClient($name); $movieData = $movie->getMovie($movieName); // If selected client and movie is reachable: if (isset($clientData[0]) || isset($movieData[0])) { $recentStatus = last($clientData[0]['Details'])['Status']; $recentMovie = last($clientData[0]['Details'])['Movie']; // If correct rental status and movie at most recent detail: if ($recentStatus == 'Rented' && $recentMovie == $movieName) { // Set input data to client details $input = ['Movie' => $movieName] + ['Status' => 'Returned'] + ['Date' => $time->format('Y-m-d H:i:s')]; // Add rental to client collection // If client edit successfully: if ($client->addMovie($input, $name)) { response()->json(['status' => 'success'], 201); // Edit movie status to available // If movie edit successfully: if ($movie->editMovie(['Status' => 'YES'], $movieName)) { return response()->json(['status' => 'success'], 200); } else { return response()->json(['status' => 'Failed to edit movie'], 404); } } else { return response()->json(['status' => 'Failed to add movie'], 404); } // Otherwise, most recent of client's details are incorrect: } else { return response()->json(['status' => 'Details incorrect'], 403); } // Otherwise, return failure of client or movie is not found: } else { return response()->json(['status' => 'Client or Movie not found'], 404); } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { Client::whereId($id)->delete(); return redirect('/clients'); }
/** * Return the Client associated to the Commande * @return \App\Model\Client */ function getClient() { return Client::getOneBy(array('_id' => $this->_client)); }