本文整理汇总了PHP中Unit::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Unit::select方法的具体用法?PHP Unit::select怎么用?PHP Unit::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit::select方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listingJson
/**
* function for send ajax request to view
*
* @return Response
*/
public function listingJson()
{
//$query = Building::all();
$query = Unit::select('id', 'block', 'unit_type_id', 'additional_land_area', 'additional_facility', 'changed_by')->with('User')->with('UnitType')->get();
return Datatable::collection($query)->addColumn('block', function ($model) {
return ucfirst($model->block);
})->addColumn('unit_type_id', function ($model) {
// return $model->unit_type_id;
return ucfirst($model->unitType->name);
})->addColumn('additional_land_area', function ($model) {
return $model->additional_land_area;
})->addColumn('additional_facility', function ($model) {
$additional_facility = $model->additional_facility ? 'Yes' : 'No';
return $additional_facility;
})->addColumn('changed_by', function ($model) {
return $model->user->name;
// return $model->changed_by;
})->addColumn('show', function ($model) {
return '<a href="' . action('UnitsController@detail', $model->id) . '" class="btn btn-small btn-primary btn-constant"><i class="fa fa-eye fa-fw"></i></a>';
})->addColumn('edit', function ($model) {
return '<a href="' . action('UnitsController@edit', $model->id) . '" class="btn btn-small btn-success btn-constant"><i class="fa fa-edit fa-fw"></i></a>';
})->addColumn('delete', function ($model) {
return '<form action="' . action('UnitsController@delete', $model->id) . '" method="POST"><button type="submit" class="btn btn-small btn-danger btn-constant" onclick = "return confirm(\'Are you sure?\')"><i class="fa fa-times fa-fw"></i></button></form>';
})->searchColumns('block', 'additional_land_area', 'status_id')->orderColumns('id', 'block', 'unit_type_id', 'additional_land_area', 'additional_facility')->make();
}
示例2: function
Flight::route('GET /v1/main/unit', function () {
$company = Flight::request()->query->company;
try {
if ($company) {
$array = Unit::selectByCompany($company);
} else {
$array = Unit::selectAll();
}
Flight::ok($array);
} catch (Exception $exception) {
Flight::error($exception);
}
});
Flight::route('GET /v1/main/unit/@id', function ($id) {
try {
$object = Unit::select($id);
Flight::ok($object);
} catch (Exception $exception) {
Flight::error($exception);
}
});
Flight::route('POST /v1/main/unit', function () {
try {
$object = Unit::insert();
Flight::ok($object);
} catch (Exception $exception) {
Flight::error($exception);
}
});
Flight::route('PUT /v1/main/unit/@id', function ($id) {
try {
示例3: selectByCompany
public static function selectByCompany($id)
{
$connection = Flight::dbMain();
try {
$sql = "SELECT * FROM vehicle WHERE company_id = :company;";
$query = $connection->prepare($sql);
$query->bindParam(':company', $id, PDO::PARAM_INT);
$query->execute();
$rows = $query->fetchAll(PDO::FETCH_ASSOC);
$result = array();
foreach ($rows as $row) {
$vehicle = new Vehicle();
$vehicle->Id = (int) $row['id'];
$vehicle->DtCreated = $row['vehicle_dt_created'];
$vehicle->DtSubscribed = $row['vehicle_dt_subscribed'];
$vehicle->Plate = $row['vehicle_plate'];
$vehicle->Name = $row['vehicle_name'];
$vehicle->Model = $row['vehicle_model'];
$vehicle->MaInitial = (int) $row['vehicle_ma_initial'];
$vehicle->MaLimit = (int) $row['vehicle_ma_limit'];
$vehicle->MaMaintenance = (int) $row['vehicle_ma_maintenance'];
$vehicle->SpeedMax = (int) $row['vehicle_speed_max'];
$vehicle->FuelMax = (int) $row['vehicle_fuel_max'];
// $vehicle->Status = (int)$row['e_status_id'];
// $vehicle->Driver = $row['driver_id'] == null ? null : (int)$row['driver_id'];
// $vehicle->Unit = $row['unit_id'] == null ? null : (int)$row['unit_id'];
// $vehicle->Company = (int) $row['company_id'];
// $vehicle->TrackeeType = (int) $row['e_trackee_type_id'];
$vehicle->Status = (int) $row['e_status_id'];
$vehicle->Driver = Driver::select($row['driver_id']);
$vehicle->Unit = Unit::select($row['unit_id']);
$vehicle->Company = Company::select($row['company_id']);
$vehicle->TrackeeType = TrackeeType::select($row['e_trackee_type_id']);
$vehicle->Status = Status::select($row['e_status_id']);
array_push($result, $vehicle);
}
return $result;
} catch (PDOException $pdoException) {
throw $pdoException;
} catch (Exception $exception) {
throw $exception;
} finally {
$connection = null;
}
}