本文整理汇总了PHP中State::all方法的典型用法代码示例。如果您正苦于以下问题:PHP State::all方法的具体用法?PHP State::all怎么用?PHP State::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类State
的用法示例。
在下文中一共展示了State::all方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: packages
public function packages()
{
$view = $this->getActionView();
$states = State::all();
$view->set('states', $states);
$source = RequestMethods::get('source');
$source_state = State::first(array('id = ?' => $source));
$dest = RequestMethods::get('dest');
$dest_state = State::first(array('id = ?' => $dest));
$month = RequestMethods::get('month');
$year = RequestMethods::get('year');
$page = RequestMethods::get('page', 1);
$limit = 9;
if (RequestMethods::get('source')) {
$count = Package::count(array('source Like ?' => $source, 'destination Like ?' => $dest, 'month = ?' => $month, 'year = ?' => $year));
$total_pages = $count / 9 + 1;
for ($i = 1; $i <= $total_pages; $i++) {
$pages[$i] = $i;
}
$packages = Package::all(array('source Like ?' => $source, 'destination Like ?' => $dest, 'month = ?' => $month, 'year = ?' => $year, 'live = ?' => 1), array("*"), null, null, $limit, $page);
$view->set('n', 'http://planyourtours.io/travels/packages?source=' . $source . '&dest=' . $dest . '&type=Group&month=' . $month . '&year=' . $year . '&page=')->set('source', $source_state)->set('dest', $dest_state)->set('month', $month)->set('year', $year);
} else {
$count = Package::count();
$total_pages = $count / 9 + 1;
for ($i = 1; $i <= $total_pages; $i++) {
$pages[$i] = $i;
}
$packages = Package::all(array('live = ?' => 1), array("*"), null, null, $limit, $page);
$view->set('n', 'http://planyourtours.io/travels/packages?&page=');
}
if (!empty($packages)) {
$view->set('packages', $packages)->set('pages', $pages);
}
}
示例2: personalinfo
public function personalinfo()
{
$driver = User::first(array('id = ?' => $this->user->id));
if ($driver->cab_driver == 1) {
$view = $this->getActionView();
$states = State::all();
$countries = Country::all();
$driver = CabDriver::first(array('user_id = ?' => $this->user->id));
$view->set('states', $states)->set('countries', $countries)->set('driver', $driver);
if (RequestMethods::post('full_name')) {
$driver->full_name = RequestMethods::post('full_name');
$driver->contact = RequestMethods::post('contact');
$driver->country = RequestMethods::post('country');
$driver->state = RequestMethods::post('state');
$driver->pincode = RequestMethods::post('pin');
$driver->address = RequestMethods::post('address');
$driver->pinfo_flag = '1';
if ($driver->validate()) {
$driver->save();
header("Location: /driver/vehicleinfo");
} else {
$view->set('error', "validation not good");
}
}
} else {
header('/');
}
}
示例3: index
public function index()
{
$schools = School::all();
$states = State::all();
$cities = City::where('state_id', '=', 25)->get();
$menu = 'data';
return View::make('schools.index', compact('schools', 'states', 'cities', 'menu'));
}
示例4: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
// Se verifica la información a embeber.
$this->getEagerLoad();
// Se consultan los datos teniendo en cuenta la información a embeber.
$statesList = State::all();
return $this->respondWithCollection($statesList, new StateTransformer());
}
示例5: index
public function index()
{
$view = $this->getActionView();
$states = State::all();
$limit = 3;
$page = 1;
$packages = Package::all(array(), array("*"), null, null, $limit, $page);
$view->set('states', $states)->set('packages', $packages);
}
示例6: myaccount
public function myaccount()
{
$view = $this->getActionView();
$states = State::all();
$countries = Country::all();
$view->set('states', $states)->set('countries', $countries);
if (RequestMethods::post('update')) {
$user = User::first(array('id = ?' => $this->user->id));
$user->full_name = RequestMethods::post('full_name');
$user->country = RequestMethods::post('country');
$user->state = RequestMethods::post('state');
$user->pincode = RequestMethods::post('pin');
$user->address = RequestMethods::post('address');
if ($user->validate) {
$user->save();
} else {
echo "validation not good";
}
}
}
示例7: getProfileData
/**
* Obtiene la información de un perfil
*
* @param Profile $profile perfil del cual obtener los datos
* @return array arreglo que contiene la información del perfil
*/
public static function getProfileData($profile)
{
$profile->load('city.state.cities', 'city.sports', 'profileValues.field.values.parent', 'profileValues.value');
$roles = Role::all()->lists('description', 'idRole');
$states = State::all()->lists('description', 'idState');
$cities = $profile->city->state->cities->lists('description', 'idCity');
$sports = $profile->city->sports->filter(function ($sport) {
return $sport->description != "Otro";
});
$sports->add(Sport::where("description", "=", "Otro")->first());
$sports = $sports->lists('description', 'idSport');
$fields = array();
foreach ($profile->profileValues as $profileValue) {
$parent = $profileValue->value->parent->first();
self::solveParentValue($fields, $profileValue->field, $parent);
self::addField($fields, $profileValue->field, $profileValue->value, $parent);
}
$data = array('roles' => $roles, 'states' => $states, 'cities' => $cities, 'sports' => $sports, 'fields' => $fields, 'profile' => $profile);
return $data;
}
示例8: editar
public function editar($id)
{
if (!$id) {
$this->session->set_flashdata('msg', '<div class="notice">El alumno solicitado no existe.</div>');
redirect('alumnos');
} elseif ($_POST) {
$this->load->helper('date');
$this->load->library('Utils');
$insert = $_POST;
$insert['fecha_nacimiento'] = $this->utils->fecha_formato('%Y-%m-%d', $insert['fecha_nacimiento']);
$insert['fecha_inscripcion'] = $this->utils->fecha_formato('%Y-%m-%d', $insert['fecha_inscripcion']);
$alumno = Student::find($id);
$alumno->update_attributes(elements(array('city_id', 'nombre', 'apellido', 'fecha_nacimiento', 'sexo', 'tipo_documento', 'nro_documento', 'domicilio', 'tenencia', 'nacionalidad', 'grupo_sanguineo', 'telefono', 'celular', 'obs_medicas', 'observaciones', 'colegio_procedencia', 'fecha_inscripcion'), $insert));
if ($alumno->is_valid()) {
if ($alumno->save()) {
$this->session->set_flashdata('msg', '<div class="success">El alumno se guardó correctamente.</div>');
redirect($this->agent->referrer());
} else {
$this->session->set_flashdata('msg', '<div class="error">Hubo un error al guardar los datos.</div>');
redirect($this->agent->referrer());
}
} else {
$data['errors'] = $alumno->errors;
}
} else {
$data['a'] = Student::find($id);
}
$data['paises'] = Country::all();
$data['provincias'] = State::all();
$data['ciudades'] = City::all();
$data['titulo'] = "Editar alumno";
$data['action'] = "alumnos/editar/" . $id;
$this->template->write_view('content', 'alumnos/agregar', $data);
$this->template->render();
}
示例9: editar
public function editar($id)
{
if (!$id) {
$this->session->set_flashdata('msg', '<div class="error">La ciudad solicitada no existe.</div>');
redirect('ciudades');
} elseif ($_POST) {
$this->load->helper('date');
$this->load->library('Utils');
$ciudad = City::find($id);
$ciudad->update_attributes(elements(array('nombre', 'state_id'), $_POST));
if ($ciudad->is_valid()) {
if ($ciudad->save()) {
$this->session->set_flashdata('msg', '<div class="success">La ciudad se guardó correctamente.</div>');
redirect('ciudades');
} else {
$this->session->set_flashdata('msg', '<div class="error">Hubo un error al guardar los datos.</div>');
redirect('ciudades/editar/' . $id);
}
} else {
$data['errors'] = $ciudad->errors;
}
} else {
$data['a'] = City::find($id);
}
$data['paises'] = Country::all();
$data['provincias'] = State::all();
$data['titulo'] = "Editar Ciudad";
$data['action'] = "ciudades/editar/" . $id;
$this->template->write_view('content', 'ciudades/agregar', $data);
$this->template->render();
}
示例10: search
public function search()
{
$view = $this->getActionView();
$states = State::all();
$view->set('states', $states);
$source = RequestMethods::get('source');
$source_state = State::first(array('id = ?' => $source));
$dest = RequestMethods::get('dest');
$dest_state = State::first(array('id = ?' => $dest));
$people = RequestMethods::get('people');
$start = RequestMethods::get('start');
$end = RequestMethods::get('end');
$drivers = CabDriver::all(array('state = ?' => RequestMethods::get('source')));
$startdate = strtotime($start);
$enddate = strtotime($end);
$today = strtotime(date('Y-m-d'));
$i = 0;
foreach ($drivers as $driver) {
$bookings = CabBooking::all(array('driver_id = ?' => $driver->id));
$flag = 0;
foreach ($bookings as $booking) {
$booking_startdate = strtotime($booking->startdate);
$booking_enddate = strtotime($booking->enddate);
if ($startdate < $enddate) {
$flag = 1;
break;
}
if ($startdate < $today) {
$flag = 1;
break;
}
if ($startdate >= $booking_startdate && $enddate <= $booking_enddate || $startdate <= $booking_startdate && $enddate >= $booking_enddate || $startdate <= $booking_startdate && $enddate <= $booking_enddate && $enddate >= $booking_startdate || $startdate >= $booking_startdate && $startdate <= $booking_enddate && $enddate >= $booking_enddate) {
$flag = 1;
break;
}
}
if ($driver->seater < RequestMethods::get('people')) {
$flag = 1;
}
if ($flag == 0) {
$available_drivers[$i] = $driver->id;
$i++;
}
}
$view->set('source', $source_state)->set('dest', $dest_state)->set('start', $start)->set('end', $end)->set('people', $people);
if (!empty($available_drivers)) {
$view->set('drivers', $available_drivers);
foreach ($available_drivers as $driver) {
$type_e = CabDriver::first(array('id = ?' => $driver));
if ($type_e->type == 'economy') {
$view->set('type1', '');
break;
}
}
foreach ($available_drivers as $driver) {
$type_e = CabDriver::first(array('id = ?' => $driver));
if ($type_e->type == 'premium') {
$view->set('type2', '');
break;
}
}
}
if ($this->user) {
if (RequestMethods::post('car')) {
foreach ($available_drivers as $driver) {
$cab = CabDriver::first(array('id = ?' => $driver, 'car_name = ?' => RequestMethods::post('car')));
break;
}
if ($cab) {
$booking = new CabBooking(array('user_id' => $this->user->id, 'driver_id' => $cab->id, 'startdate' => $start, 'enddate' => $end, 'startplace' => $source, 'endplace' => $dest));
if ($booking->validate()) {
$booking->save();
header('/cab/confirmation/' . $booking->id);
}
} else {
echo "<script> alert('Something went wrong') </script>";
}
}
} else {
echo "<script> alert('login first') </script>";
}
}
示例11: getStates
public function getStates()
{
if (Request::ajax()) {
return State::all();
}
}
示例12: create_package
/**
* @before _secure, changeLayout
*/
public function create_package()
{
$this->seo(array("title" => "Dashboard", "view" => $this->getLayoutView()));
$view = $this->getActionView();
$states = State::all();
$view->set('states', $states);
if (RequestMethods::post('name')) {
$imageFileType1 = pathinfo($_FILES["package1"]["name"], PATHINFO_EXTENSION);
if (!empty($_FILES["package2"]["name"])) {
$imageFileType2 = pathinfo($_FILES["package2"]["name"], PATHINFO_EXTENSION);
} else {
$imageFileType2 = NULL;
}
if (!empty($_FILES["package3"]["name"])) {
$imageFileType3 = pathinfo($_FILES["package3"]["name"], PATHINFO_EXTENSION);
} else {
$imageFileType3 = NULL;
}
if (!empty($_FILES["package4"]["name"])) {
$imageFileType4 = pathinfo($_FILES["package4"]["name"], PATHINFO_EXTENSION);
} else {
$imageFileType4 = NULL;
}
if (!empty($_FILES["package5"]["name"])) {
$imageFileType5 = pathinfo($_FILES["package5"]["name"], PATHINFO_EXTENSION);
} else {
$imageFileType5 = NULL;
}
$package = new Package(array('name' => RequestMethods::post('name'), 'source' => RequestMethods::post('source'), 'destination' => RequestMethods::post('dest'), 'desc' => RequestMethods::post('desc'), 'start_date' => RequestMethods::post('startdate'), 'end_date' => RequestMethods::post('enddate'), 'month' => RequestMethods::post('month'), 'year' => RequestMethods::post('year'), 'price' => RequestMethods::post('price'), 'people' => RequestMethods::post('people'), 'people_left' => RequestMethods::post('people'), 'imgext1' => $imageFileType1, 'imgext2' => $imageFileType2, 'imgext3' => $imageFileType3, 'imgext4' => $imageFileType4, 'imgext5' => $imageFileType5));
if ($package->validate()) {
$package->save();
$view->set('success', 'success');
$count = Package::count();
$target_dir = "/public/uploads/packages/";
$target_file = APP_PATH . $target_dir . $count . '_';
$img = 0;
// Check if image file is a actual image or fake image
$check = getimagesize($_FILES["package1"]["tmp_name"]);
if ($check !== false) {
$img++;
}
if ($imageFileType1 != "jpg" && $imageFileType1 != "png" && $imageFileType1 != "jpeg" && $_FILES["package"]["size"] > 5000000) {
$img--;
}
if ($img == 1) {
$flag = 0;
if (move_uploaded_file($_FILES["package1"]["tmp_name"], $target_file . '1.' . $imageFileType1)) {
$flag++;
}
if ($flag == 1) {
} else {
$view->set('errorimg', 'Error in first image. Not uploaded');
}
}
if (!empty($imageFileType2)) {
$img = 0;
// Check if image file is a actual image or fake image
$check = getimagesize($_FILES["package2"]["tmp_name"]);
if ($check !== false) {
$img++;
}
if ($imageFileType2 != "jpg" && $imageFileType2 != "png" && $imageFileType2 != "jpeg" && $_FILES["package2"]["size"] > 5000000) {
$img--;
}
if ($img == 1) {
$flag = 0;
if (move_uploaded_file($_FILES["package2"]["tmp_name"], $target_file . '2.' . $imageFileType2)) {
$flag++;
}
if ($flag == 1) {
} else {
$view->set('errorimg', 'Error in second image. Not uploaded');
}
}
}
if (!empty($imageFileType3)) {
$img = 0;
// Check if image file is a actual image or fake image
$check = getimagesize($_FILES["package3"]["tmp_name"]);
if ($check !== false) {
$img++;
}
if ($imageFileType3 != "jpg" && $imageFileType3 != "png" && $imageFileType3 != "jpeg" && $_FILES["package3"]["size"] > 5000000) {
$img--;
}
if ($img == 1) {
$flag = 0;
if (move_uploaded_file($_FILES["package3"]["tmp_name"], $target_file . '3.' . $imageFileType3)) {
$flag++;
}
if ($flag == 1) {
} else {
$view->set('errorimg', 'Error in third image. Not uploaded');
}
}
}
if (!empty($imageFileType4)) {
//.........这里部分代码省略.........
示例13: getState
public function getState()
{
$staesp = State::all();
if (count($staesp) > 0) {
return Response::json($staesp);
} else {
return Response::json(array('status' => 'failure', 'message' => 'There is No state in State Table'));
}
}
示例14: editar
public function editar($id)
{
if ($this->session->userdata('grupo') == 'admin' or $this->session->userdata('id') == $id) {
if (!$id) {
$this->session->set_flashdata('msg', '<div class="notice">El usuario solicitado no existe.</div>');
redirect('usuarios');
} elseif ($_POST) {
$this->load->helper('date');
$this->load->library('Utils');
$insert = $_POST;
$usuario = User::find($id);
$usuario->update_attributes(elements(array('nombre', 'apellido', 'direccion', 'telefono', 'email', 'celular', 'usuario', 'grupo', 'password'), $insert));
if ($usuario->is_valid()) {
if ($usuario->save()) {
$this->session->set_flashdata('msg', '<div class="success">El usuario se guardó correctamente.</div>');
redirect($this->agent->referrer());
} else {
$this->session->set_flashdata('msg', '<div class="error">Hubo un error al guardar los datos.</div>');
redirect($this->agent->referrer());
}
} else {
$data['errors'] = $usuario->errors;
}
} else {
$data['a'] = User::find($id);
}
$data['paises'] = Country::all();
$data['provincias'] = State::all();
$data['ciudades'] = City::all();
$data['titulo'] = "Editar usuario";
$data['action'] = "usuarios/editar/" . $id;
$this->template->write_view('content', 'usuarios/agregar', $data);
$this->template->render();
} else {
$this->session->set_flashdata('msg', '<div class="error">No tiene privilegios para realizar esta acción.</div>');
redirect('usuarios/index/');
}
}