本文整理汇总了PHP中Vehicle::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Vehicle::save方法的具体用法?PHP Vehicle::save怎么用?PHP Vehicle::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vehicle
的用法示例。
在下文中一共展示了Vehicle::save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insert_vehicles
public function insert_vehicles(Request $request)
{
$vehicle = new Vehicle();
$vehicle->vehicle_model = $request->input('model');
$vehicle->vehicle_number = $request->input('vehi_num');
$vehicle->vehicle_type = $request->input('type');
$vehicle->remarks = $request->input('remarks');
$vehicle->save();
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$validator = Validator::make(Input::all(), Vehicle::$rules, Vehicle::$messages);
if ($validator->passes()) {
$vehicle = new Vehicle();
$vehicle->chasis = Input::get('chasis');
$vehicle->enginecc = Input::get('enginecc');
$vehicle->engineno = Input::get('engineno');
$vehicle->yor = Input::get('yor');
$vehicle->destination = Input::get('destination');
$vehicle->make = Input::get('make');
$vehicle->model = Input::get('model');
$vehicle->location_id = Input::get('location_id');
$vehicle->vec = '';
$vehicle->inspection_date = Input::get('inspection_date');
$vehicle->charge = Location::find(Input::get('location_id'))->location_charge;
$vehicle->user_id = Auth::id();
$vehicle->save();
$file = Input::file('vec');
$extension = $file->getClientOriginalExtension();
$fileName = "VEC" . $vehicle->id . '.' . $extension;
$vehicle->vec = $fileName;
$vehicle->save();
$file->move('uploads', $fileName);
//Upload the file to public/uploads
// CREATE NEW VEHICLE INSPECTION RECORD
$insp = new VehicleInspection();
$insp->vehicle_id = $vehicle->id;
$insp->save();
//CREATE NEW VEHICLE ROADWORTHINESS RECORD
$insp_details = new InspectorDetails();
$insp_details->vehicle_id = $vehicle->id;
$insp_details->save();
//Event::fire('vehicle.create', [$vehicle]);
return Redirect::to('vehicles')->with('success', 'Vehicle Added Successfully');
} else {
return Redirect::to('vehicles/create')->withErrors($validator)->withInput();
}
}
示例3: actionCreate
/** Creates a new model. If creation is successful, the browser will be redirected to the 'show' page. */
public function actionCreate()
{
$model = new Vehicle();
if (isset($_POST['Vehicle'])) {
// Submit
$model->attributes = $_POST['Vehicle'];
// Additional attributes
// mmmm.. no me gusta mucho a nivel de seguridad
// y encima tengo que meter un hidden en el form para que lo devuelva!!!
//!!!! // paliado chequeando que sea un admin al menos
if (!empty($_POST['uid']) && Yii::app()->user->checkAccess('adminVehicles')) {
// Submit
// Force uid by an admin
$model->uid = $_REQUEST['uid'];
Yii::app()->user->setState('userMarked', $_REQUEST['uid']);
} else {
$model->uid = Yii::app()->user->id ? Yii::app()->user->id : 0;
}
$model->created = time();
$model->changed = time();
// Save time
if ($model->save()) {
Flashes::addInfoFlash(Yii::t('amo', 'Vehicle created successfully'));
if ($_REQUEST['submitAndNew']) {
$this->refresh();
} else {
$this->redirect(array('show', 'id' => $model->vid));
}
} else {
Flashes::addErrorFlash(Yii::t('amo', 'Could not create vehicle.') . ' ' . Yii::t('amo', 'Please, try again later.'));
}
}
// RENDER THE FORM: Send uid and username
$uidMarked = Yii::app()->user->getState('userMarked');
if (!empty($uidMarked)) {
$user = User::model()->findbyPk($uidMarked);
}
$this->render('create', array('model' => $model, 'uid' => $uidMarked, 'username' => $user->name));
}
示例4: array
$data_compra->setRestriccio(true);
$combustible = $form->crearElement("combustible");
$combustible->setTipus("seleccio", array('Electric', 'Diesel', 'Gasolina'));
$combustible->setRestriccio(true);
$asseguranca = $form->crearElement("asseguranca");
$asseguranca->setTipus("numeric");
$asseguranca->setRestriccio(false);
include 'classes/Llistes/LlistaModels.php';
$models = new LlistaModels();
if (count($_POST)) {
if ($form->valida($_POST)) {
$infos = array();
array_push($infos, $matricula, $model, $color, $data_compra, $combustible, $asseguranca);
$vehicle = new Vehicle();
$vehicle->setInfos($infos);
if ($vehicle->save()) {
header('location: afegir_vehicle.php?inserit=' . $matricula->getValor());
exit;
} else {
$errors = $vehicle->getErrors();
echo "ups";
}
} else {
$errors = $form->mostrarErrors();
}
} else {
$errors = $form->mostrarErrors();
}
?>