本文整理汇总了PHP中app\models\Location::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Location::select方法的具体用法?PHP Location::select怎么用?PHP Location::select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Location
的用法示例。
在下文中一共展示了Location::select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDatatable
/**
* Returns the JSON response to populate the bootstrap tables on the locationa view.
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @see LocationsController::getIndex() method that returns JSON for location index
* @since [v1.0]
* @return View
*/
public function getDatatable()
{
$locations = Location::select(array('locations.id', 'locations.name', 'locations.address', 'locations.address2', 'locations.city', 'locations.state', 'locations.zip', 'locations.country', 'locations.parent_id', 'locations.currency'))->with('assets');
if (Input::has('search')) {
$locations = $locations->TextSearch(e(Input::get('search')));
}
if (Input::has('offset')) {
$offset = e(Input::get('offset'));
} else {
$offset = 0;
}
if (Input::has('limit')) {
$limit = e(Input::get('limit'));
} else {
$limit = 50;
}
$order = Input::get('order') === 'asc' ? 'asc' : 'desc';
switch (Input::get('sort')) {
case 'parent':
$locations = $locations->OrderParent($order);
break;
default:
$allowed_columns = ['id', 'name', 'address', 'city', 'state', 'country', 'currency'];
$sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
$locations = $locations->orderBy($sort, $order);
break;
}
$locationsCount = $locations->count();
$locations = $locations->skip($offset)->take($limit)->get();
$rows = array();
foreach ($locations as $location) {
$actions = '<nobr><a href="' . route('update/location', $location->id) . '" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a><a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/location', $location->id) . '" data-content="' . trans('admin/locations/message.delete.confirm') . '" data-title="' . trans('general.delete') . ' ' . htmlspecialchars($location->name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a></nobr>';
$rows[] = array('id' => $location->id, 'name' => (string) link_to('admin/settings/locations/' . $location->id . '/view', e($location->name)), 'parent' => $location->parent ? e($location->parent->name) : '', 'assets_default' => $location->assignedassets->count(), 'assets_checkedout' => $location->assets->count(), 'address' => $location->address ? e($location->address) : '', 'city' => e($location->city), 'state' => e($location->state), 'country' => e($location->country), 'currency' => e($location->currency), 'actions' => $actions);
}
$data = array('total' => $locationsCount, 'rows' => $rows);
return $data;
}