/** * Store a newly created hotel in storage. * * @return Response */ public function store() { $validator = Validator::make($data = Input::all(), Hotel::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } Hotel::create($data); return Redirect::route('hotels.index'); }
public function run() { // Uncomment the below to wipe the table clean before populating DB::table('hotels')->truncate(); // Uncomment the below to run the seeder Hotel::create(array('name' => 'The Lantern Inn', 'brand_id' => 2, 'zip' => 82010)); Hotel::create(array('name' => 'Countryside Suites', 'brand_id' => 4, 'zip' => 42500)); Hotel::create(array('name' => 'The Garden Hotel, Phoenix', 'brand_id' => 3, 'zip' => 86000)); Hotel::create(array('name' => 'Fairway Hotel', 'brand_id' => 2, 'zip' => 93240)); Hotel::create(array('name' => 'Plainview Inn', 'brand_id' => 2, 'zip' => 65001)); Hotel::create(array('name' => 'Flyaway Hotel', 'brand_id' => 1, 'zip' => 23450)); }
<?php require_once "../../includes/initialize.php"; if (isset($_POST['submit'])) { $hotel = new Hotel(); $hotel->hotel_name = $_POST['hotel_name']; $hotel->password = $_POST['password']; $hotel->city = $_POST['city']; $hotel->info = $_POST['info']; if ($hotel->create()) { redirect_to("test2.php?id={$hotel->id}"); } } ?> <form action="test.php" method="post"> <p>Hotel name: <input type="text" name="hotel_name" value=""> </p> <p>Password: <input type="password" name="password" value=""> </p> <p>City: <input type="text" name="city" value=""> </p> <p>Info: <textarea cols="80" rows="20" name="info"></textarea>
$name = $database->escapeString($_POST['name']); $address = $database->escapeString($_POST['address']); $stars = $database->escapeString($_POST['stars']); $destination = $database->escapeString($_POST['location']); $description = $database->escapeString($_POST['description']); $hotel->setHotelName($name); $hotel->setAddress($address); $hotel->setStars($stars); $hotel->setDescription($description); $hotel->setCityId($destination); if (isset($_POST['hotelId'])) { $hotelId = $database->escapeString($_POST['hotelId']); $hotel->setHotelId($hotelId); $hotel->update($database); } else { $hotelId = $hotel->create($database); } if (count($_FILES) != 0) { $error = 0; $files = array(); $uploaddir = "../images/hotels/large/"; $uploaddirthumb = "../images/hotels/thumb/"; $nameArray = $_FILES['mediaUploads']['name']; $typeArray = $_FILES['mediaUploads']['type']; $tmpNameArray = $_FILES['mediaUploads']['tmp_name']; $errorArray = $_FILES['mediaUploads']['error']; $sizeArray = $_FILES['mediaUploads']['size']; for ($count = 0; $count < count($_FILES['mediaUploads']['name']); $count++) { $randomNrForName = rand(1, 9999999999.0); $target_file = $uploaddir . $randomNrForName . basename($nameArray[$count]); $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);
public function run() { $hotel = Hotel::create(['departamento' => 'Lambayeque', 'direccion' => 'Alfonso Ugarte #1234', 'nombre' => 'Hotel Alfonso Ugarte', 'provincia' => 'Chiclayo', 'razonsocial' => 'Hotel Alfonso Ugarte', 'ruc' => 2467890]); $persona = Persona::create(['nombre' => 'Administrador']); Usuario::create(['hotel_id' => $hotel->id, 'perfil_id' => 1, 'persona_id' => $persona->id, 'login' => 'Administrador', 'password' => \Hash::make(123456)]); }