本文整理汇总了PHP中Vehicle::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Vehicle::create方法的具体用法?PHP Vehicle::create怎么用?PHP Vehicle::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vehicle
的用法示例。
在下文中一共展示了Vehicle::create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
Vehicle::create(array('id' => 1, 'plate' => 'GNM504', 'color' => 'Rojo', 'brand' => 'Renault', 'model' => 'Twingo 2007', 'capacity' => 4, 'status' => 1, 'type' => 1, 'users_id' => 1));
Vehicle::create(array('id' => 2, 'plate' => 'FKJ324', 'color' => 'Azul', 'brand' => 'Renault', 'model' => 'Clio 2008', 'capacity' => 2, 'status' => 1, 'type' => 1, 'users_id' => 2));
Vehicle::create(array('id' => 3, 'plate' => 'HJJ832', 'color' => 'Verde', 'brand' => 'Renault', 'model' => 'Sandero 2010', 'capacity' => 2, 'status' => 1, 'type' => 1, 'users_id' => 3));
Vehicle::create(array('id' => 4, 'plate' => 'FMJ313', 'color' => 'Negro', 'brand' => 'Ford', 'model' => 'Fordsito 2014', 'capacity' => 3, 'status' => 1, 'type' => 1, 'users_id' => 4));
}
示例2: store
public function store()
{
$vehicle = Input::all();
$vehicle['users_id'] = Auth::user()->id;
$vehicle['status'] = true;
Vehicle::create($vehicle);
return json_encode($vehicle);
}
示例3: changeOwnerUpdate
public function changeOwnerUpdate($id)
{
// FIND OLD VEHICLE AND CREATE RESPECTIVE LOGS
$oldVehicle = Vehicle::find($id);
/*
// IF VEHICLE STATUS IS CHANGED, ADD OLD STATUS IN LOG AND UPDATE DATA
if($oldVehiclesStatus != $newVehiclesStatus){
LogVehicleStatus::create(['log_vehicle_status_vehicle_id' => $id, 'log_vehicle_status_vehicle_status_id' => $oldVehiclesStatus]);
}
// IF VEHICLE COLOR IS CHANGED, ADD OLD COLOR IN LOG AND UPDATE DATA
if($oldvehicleColor != $newVehicleColor){
LogVehicleColor::create(['log_vehicle_color_vehicle_id' => $id, 'log_vehicle_color_color_id' => $oldvehicleColor]);
}
// IF VEHICLE USE TYPE IS CHANGED, ADD OLD USE TYPE IN LOG AND UPDATE DATA
if($oldVehicleUseType != $newVehicleUseType){
$oldRegistrations_no = $oldVehicle->registration->registrations_no;
LogVehicleUseType::create(['log_vehicle_use_type_vehicle_id' => $id, 'log_vehicle_use_type_use_type' => $oldVehicleUseType, 'log_vehicle_use_type_registration_no' => $oldRegistrations_no]);
}
*
// TAKE LOG OF ODOMETER
$vehicles_odometer = trim(Input::get('vehicles_odometer'));
$oldOdometer = Vehicle::find($id)->vehicles_odometer;
LogVehicleOdometer::create(['log_vehicle_odometer_vehicle_id' => $id, 'log_vehicle_odometer_old_odometer' => $oldOdometer]);
*/
//VEHICLE DATA
$vehicles_year = trim(Input::get('vehicles_year'));
$vehicles_make_id = trim(Input::get('vehicles_make_id'));
$vehicles_name_trim = trim(Input::get('vehicles_name_trim'));
$vehicles_name_trim_ar = explode(',', $vehicles_name_trim);
$model_name = trim($vehicles_name_trim_ar[0]);
if (count($vehicles_name_trim_ar) > 1) {
$model_trim = trim($vehicles_name_trim_ar[1]);
} else {
$model_trim = "";
}
$vehicles_body = trim(Input::get('vehicles_body'));
if ($vehicles_body == -1) {
$vehicles_body = "";
}
$vehicles_weight_kg = trim(Input::get('vehicles_weight_kg'));
// BEGIN VEHICLE
// IF VEHICLE BODY IS NOT BLANK THEN ADD BODY, ELSE IGNORE IT TO MAKE IT NULL
if ($vehicles_body != "") {
$vehicle = Input::only(['vehicles_vin', 'vehicles_year', 'vehicles_make_id', 'vehicles_name_trim', 'vehicles_body', 'vehicles_weight_kg', 'vehicles_use_type', 'vehicles_use_type', 'vehicles_class', 'vehicles_color', 'vehicles_status', 'vehicles_odometer']);
} else {
$vehicle = Input::only(['vehicles_vin', 'vehicles_year', 'vehicles_make_id', 'vehicles_name_trim', 'vehicles_weight_kg', 'vehicles_use_type', 'vehicles_use_type', 'vehicles_class', 'vehicles_color', 'vehicles_status', 'vehicles_odometer']);
}
//$validator_vehicle = Validator::make($vehicle, Vehicle::$rules);
//if($validator_vehicle->passes()){
// GETTING AND ADDING MODEL ID
// IF BODY IS NULL
if ($vehicles_body == "") {
// GETTING MODEL
$vehicle['vehicles_model_id'] = Model::where('model_year', $vehicles_year)->where('model_make_id', $vehicles_make_id)->where('model_name', $model_name)->where('model_trim', $model_trim)->whereNull('model_body')->first()->id;
} else {
$vehicle['vehicles_model_id'] = Model::where('model_year', $vehicles_year)->where('model_make_id', $vehicles_make_id)->where('model_name', $model_name)->where('model_trim', $model_trim)->where('model_body', $vehicles_body)->first()->id;
}
// INSERT VEHICLE DATA AND GET ID
$vehicle_inserted_id = Vehicle::create($vehicle)->id;
//}else
// return Redirect::route('vehicle.create')->withErrors($validator_vehicle)->withInput();
// END VEHICLE
// ASSOCTIATE NEW VEHICLE AND THEN DELETE OLD VEHICLE DATA
$old_vehicle = Vehicle::find($id);
// ASSOCIATE NEW VEHICLE WITH OLD VEHICLE
$old_vehicle->update(['vehicles_transfer' => $vehicle_inserted_id]);
// DELETE INSURANCE
if ($old_vehicle->insurance) {
$old_vehicle->insurance->delete();
}
// DELETE LIEN
if ($old_vehicle->lien) {
$old_vehicle->lien->delete();
}
// DELETE REGISTRATION
$old_vehicle->registration->delete();
// DELETE VEHICLE
$old_vehicle->delete();
// BEGIN OWNERS
$owners_index = Input::get('owners_index');
$owners_index_arr = array_filter(explode(',', $owners_index));
// LOOP THROUGH EACH OWNER AND ASSOCIATE WITH DRIVERS
foreach ($owners_index_arr as $owners_index_id) {
$drivers_license_no = Input::get('drivers_license_no' . $owners_index_id);
if (trim($drivers_license_no) != "") {
$drivers_status = Driver::where('drivers_license_no', $drivers_license_no)->first();
// IF DRIVER DOESN'T EXISTS, CREATE DRIVER
if ($drivers_status == NULL) {
$owner_info['drivers_fname'] = Input::get('drivers_fname' . $owners_index_id);
$owner_info['drivers_mname'] = Input::get('drivers_mname' . $owners_index_id);
$owner_info['drivers_lname'] = Input::get('drivers_lname' . $owners_index_id);
$owner_info['drivers_nin'] = Input::get('drivers_nin' . $owners_index_id);
$owner_info['drivers_license_no'] = Input::get('drivers_license_no' . $owners_index_id);
$owner_info['drivers_street'] = Input::get('drivers_street' . $owners_index_id);
$owner_info['drivers_city'] = Input::get('drivers_city' . $owners_index_id);
$owner_info['drivers_po_box'] = Input::get('drivers_po_box' . $owners_index_id);
$owner_info['drivers_country'] = Input::get('drivers_country' . $owners_index_id);
//.........这里部分代码省略.........
示例4:
<?php
/**
* Copyright (c) 2014 Keith Casey.
*
* This code is designed to accompany the lynda.com video course "Design Patterns in PHP"
* by Keith Casey. If you've received this code without seeing the videos, go watch the
* videos. It will make way more sense and be more useful in general.
*/
include_once 'vehicle.php';
$car = Vehicle::create('car', 4);
echo $car->getType();
echo '<br />';
$truck = Vehicle::create('truck', 18);
echo $truck->getType();