本文整理匯總了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;
}