本文整理汇总了PHP中Datatable::collection方法的典型用法代码示例。如果您正苦于以下问题:PHP Datatable::collection方法的具体用法?PHP Datatable::collection怎么用?PHP Datatable::collection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Datatable
的用法示例。
在下文中一共展示了Datatable::collection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUsersDataTable
public function getUsersDataTable()
{
$query = UserModel::select('username', 'roles', 'id')->get();
return Datatable::collection($query)->addColumn('id', function ($model) {
return '<a href="/users/' . $model->id . '">view</a>';
})->searchColumns('username', 'roles')->orderColumns('username', 'roles')->make();
}
示例2: org_list
/**
* This function is used to display the list of Organizations
* @return datatable
*/
public function org_list()
{
return \Datatable::collection(Organization::all())->searchColumns('name')->orderColumns('name', 'website')->addColumn('name', function ($model) {
return $model->name;
})->addColumn('website', function ($model) {
$website = $model->website;
return $website;
})->addColumn('phone', function ($model) {
$phone = $model->phone;
return $phone;
})->addColumn('Actions', function ($model) {
//return '<a href=article/delete/ ' . $model->id . ' class="btn btn-danger btn-flat" onclick="myFunction()">Delete</a> <a href=article/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a> <a href=show/' . $model->id . ' class="btn btn-warning btn-flat">View</a>';
//return '<form action="article/delete/ ' . $model->id . '" method="post" onclick="alert()"><button type="sumbit" value="Delete"></button></form><a href=article/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a> <a href=show/' . $model->id . ' class="btn btn-warning btn-flat">View</a>';
return '<span data-toggle="modal" data-target="#deletearticle' . $model->id . '"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . ' </button></span> <a href="' . route('organizations.edit', $model->id) . '" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a> <a href="' . route('organizations.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
<div class="modal fade" id="deletearticle' . $model->id . '">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Are You Sure ?</h4>
</div>
<div class="modal-body">
' . $model->user_name . '
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
<a href="' . route('org.delete', $model->id) . '"><button class="btn btn-danger">delete</button></a>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>';
})->make();
}
示例3: getDatatable
/**
* getDatatable
*/
public function getDatatable()
{
$collection = Department::all();
return Datatable::collection($collection)->showColumns('name', 'right')->orderColumns('name')->searchColumns('name')->addColumn('actions', function ($model) {
return $str = '<button data-id="' . $model->id . '" class="btn btn-info btn-department">查看部门</button>';
})->make();
}
示例4: getDatatable
/**
* getHistroy(入库历史)
*/
public function getDatatable()
{
$collection = HistoryWarehouse::all();
return Datatable::collection($collection)->showColumns('date', 'identity', 'item', 'batch', 'quantity', 'position', 'operator')->searchColumns('date')->orderColumns('date', 'identity', 'item', 'batch', 'quantity', 'position', 'operator')->addColumn('date', function ($model) {
return date('Y-m-d H:i', strtotime($model->created_at));
})->make();
}
示例5: getDatatable
public function getDatatable()
{
$query = User::select('first_name', 'last_login', 'id')->get();
return Datatable::collection($query)->addColumn('last_login', function ($model) {
return date('M j, Y h:i A', strtotime($model->last_login));
})->addColumn('id', function ($model) {
return '<a href="/users/' . $model->id . '">view</a>';
})->searchColumns('name', 'last_login')->orderColumns('name', 'last_login')->make();
}
示例6: getManageUser
public function getManageUser()
{
$operator = Sentry::findAllUsersWithAccess('operator');
$operatorCollection = new Illuminate\Database\Eloquent\Collection($operator);
$data = Datatable::collection($operatorCollection)->addColumn('full_name', function ($model) {
return $model->first_name . ' ' . $model->last_name;
})->showColumns('id', 'email', 'last_login')->searchColumns('full_name', 'email', 'last_login')->orderColumns('full_name', 'email', 'last_login')->make();
$group = Group::all();
return View::make('dashboard.admin.manageuser')->with('group', $group);
}
示例7: borrowList
public function borrowList()
{
if (Datatable::shouldHandle()) {
return Datatable::collection(Book::with('author')->orderBy('id', 'desc')->get())->showColumns('id', 'title', 'amount', 'stock')->addColumn('author', function ($model) {
return $model->author->name;
})->addColumn('borrow', function ($model) {
$html = '<a href="' . route('books.borrow', $model->id) . '" class="btn btnn"> <i class="mdi-action-grade"></i> </a>';
return $html;
})->searchColumns('title', 'amount', 'author')->orderColumns('title', 'amount', 'author')->make();
}
}
示例8: getUsersDataTable
/**
* @return bool
*/
public function getUsersDataTable()
{
$query = UserModel::select('username', 'roles', 'id')->get();
return Datatable::collection($query)->searchColumns('username', 'roles')->orderColumns('username', 'roles')->addColumn('username', function ($model) {
return $model->username;
})->addColumn('roles', function ($model) {
return $model->roles;
})->addColumn('Actions', function ($model) {
return "<a href='/projectinv/public/resource/" . $model->id . "' class='btn btn-success'>View</a>";
})->make();
}
示例9: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
if (Datatable::shouldHandle()) {
$operator = Sentry::findAllUsersWithAccess('operator');
$operatorCollection = new Illuminate\Database\Eloquent\Collection($operator);
return Datatable::collection($operatorCollection)->addColumn('full_name', function ($model) {
return $model->first_name . ' ' . $model->last_name;
})->showColumns('id', 'email', 'last_login')->searchColumns('full_name', 'email', 'last_login')->orderColumns('full_name', 'email', 'last_login')->make();
}
return View::make('dashboard.admin.manageuser');
}
示例10: user_list
/**
* This function is used to display the list of users
* @return datatable
*/
public function user_list()
{
return \Datatable::collection(User::where('role', '!=', 'admin')->where('role', '!=', 'agent')->get())->searchColumns('user_name')->orderColumns('user_name', 'email')->addColumn('user_name', function ($model) {
return $model->user_name;
})->addColumn('email', function ($model) {
$email = $model->email;
return $email;
})->addColumn('phone', function ($model) {
$phone = "";
if ($model->phone_number) {
$phone = $model->ext . ' ' . $model->phone_number;
}
$mobile = "";
if ($model->mobile) {
$mobile = $model->mobile;
}
$phone = $phone . " " . $mobile;
return $phone;
})->addColumn('status', function ($model) {
$status = $model->active;
if ($status == 1) {
$stat = '<button class="btn btn-success btn-xs">Active</button>';
} else {
$stat = '<button class="btn btn-danger btn-xs">Inactive</button>';
}
return $stat;
})->addColumn('lastlogin', function ($model) {
$t = $model->updated_at;
return TicketController::usertimezone($t);
})->addColumn('Actions', function ($model) {
//return '<a href=article/delete/ ' . $model->id . ' class="btn btn-danger btn-flat" onclick="myFunction()">Delete</a> <a href=article/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a> <a href=show/' . $model->id . ' class="btn btn-warning btn-flat">View</a>';
//return '<form action="article/delete/ ' . $model->id . '" method="post" onclick="alert()"><button type="sumbit" value="Delete"></button></form><a href=article/' . $model->id . '/edit class="btn btn-warning btn-flat">Edit</a> <a href=show/' . $model->id . ' class="btn btn-warning btn-flat">View</a>';
return '<span data-toggle="modal" data-target="#deletearticle' . $model->id . '"><a href="#" ><button class="btn btn-danger btn-xs"></a> ' . \Lang::get('lang.delete') . ' </button></span> <a href="' . route('user.edit', $model->id) . '" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a> <a href="' . route('user.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>
<div class="modal fade" id="deletearticle' . $model->id . '">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Are You Sure ?</h4>
</div>
<div class="modal-body">
' . $model->user_name . '
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal" id="dismis2">Close</button>
<a href="' . route('user.delete', $model->id) . '"><button class="btn btn-danger">delete</button></a>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>';
})->make();
}
示例11: getDatatable
/**
* getDatatable
*/
public function getDatatable()
{
$collection = Order::where('order_status', 'order_stockuped')->get();
return Datatable::collection($collection)->showColumns('date', 'no', 'customer', 'status', 'actions')->orderColumns('date', 'customer')->searchColumns('date', 'no', 'customer')->addColumn('date', function ($model) {
return date('Y-m-d', strtotime($model->created_at));
})->addColumn('customer', function ($model) {
return $model->customer->name;
})->addColumn('status', function ($model) {
return get_order_status($model->order_status);
})->addColumn('actions', function ($model) {
return $str = '<button data-id="' . $model->id . '" class="btn btn-info btn-stockorder">查看货品</button>';
})->make();
}
示例12: getBreedsDataTable
public function getBreedsDataTable()
{
$query = Breed::select('name', 'species', 'description_url', 'id')->get();
return Datatable::collection($query)->addColumn('name', function ($model) {
return $model->name;
})->addColumn('species', function ($model) {
return $model->species;
})->addColumn('description_url', function ($model) {
return '<a href="' . $model->description_url . '">See Breed Description</a>';
})->addColumn('id', function ($model) {
return '<a href="/breed/' . $model->id . '">view</a>';
})->searchColumns('name', 'species')->orderColumns('name', 'species')->make();
}
示例13: getDatatable
/**
* getDatatable
*/
public function getDatatable()
{
$collection = Order::all();
return Datatable::collection($collection)->showColumns('date', 'no', 'customer', 'status', 'item_fee', 'caution_money', 'point_fee', 'credit_fee', 'pay_fee', 'amount_fee', 'remain_fee')->orderColumns('date', 'customer', 'status')->searchColumns('date', 'no', 'customer', 'status')->addColumn('date', function ($model) {
return date('Y-m-d', strtotime($model->created_at));
})->addColumn('customer', function ($model) {
return $model->customer->name;
})->addColumn('status', function ($model) {
return get_order_status($model->order_status);
})->addColumn('remain_fee', function ($model) {
return $model->item_fee - $model->amount_fee - $model->point_fee - $model->credit_fee;
})->addColumn('actions', function ($model) {
return $str = '<button data-id="' . $model->id . '" class="btn btn-info btn-order">查看订单</button>';
})->make();
}
示例14: user_list
/**
* This function is used to display the list of users using chumper datatables
* @return datatable
*/
public function user_list()
{
// displaying list of users with chumper datatables
return \Datatable::collection(User::where('role', '!=', 'admin')->where('role', '!=', 'agent')->get())->searchColumns('user_name')->orderColumns('user_name', 'email')->addColumn('user_name', function ($model) {
if (strlen($model->user_name) > 20) {
$username = substr($model->user_name, 0, 30);
$username = substr($username, 0, strrpos($username, ' ')) . ' ...';
} else {
$username = $model->user_name;
}
return $username;
})->addColumn('email', function ($model) {
$email = $model->email;
return $email;
})->addColumn('phone', function ($model) {
$phone = "";
if ($model->phone_number) {
$phone = $model->ext . ' ' . $model->phone_number;
}
$mobile = "";
if ($model->mobile) {
$mobile = $model->mobile;
}
$phone = $phone . " " . $mobile;
return $phone;
})->addColumn('status', function ($model) {
$status = $model->active;
if ($status == 1) {
$stat = '<button class="btn btn-success btn-xs">Active</button>';
} else {
$stat = '<button class="btn btn-danger btn-xs">Inactive</button>';
}
return $stat;
})->addColumn('ban', function ($model) {
$status = $model->ban;
if ($status == 1) {
$stat = '<button class="btn btn-danger btn-xs">Banned</button>';
} else {
$stat = '<button class="btn btn-success btn-xs">Active</button>';
}
return $stat;
})->addColumn('lastlogin', function ($model) {
$t = $model->updated_at;
return TicketController::usertimezone($t);
})->addColumn('Actions', function ($model) {
return '<a href="' . route('user.edit', $model->id) . '" class="btn btn-warning btn-xs">' . \Lang::get('lang.edit') . '</a> <a href="' . route('user.show', $model->id) . '" class="btn btn-primary btn-xs">' . \Lang::get('lang.view') . '</a>';
})->make();
}
示例15: index
public function index()
{
$data = Author::all(['id', 'name']);
if (Datatable::shouldHandle()) {
return Datatable::collection($data)->showColumns('id', 'name')->addColumn('1', function ($model) {
$html = '<a href="' . route('admin.authors.edit', $model->id) . '" class="btn btnn"> <i class="mdi-editor-mode-edit"></i> </a>';
return $html;
})->addColumn('2', function ($model) {
$html = Form::open(['route' => ['admin.authors.destroy', $model->id], 'method' => 'delete']);
$html .= '<button class="btn btnn" type="submit"> <i class="mdi-action-delete"></i> </button>';
$html .= Form::close();
return $html;
})->searchColumns('name')->orderColumns('name')->make();
}
return View::make('authors.index')->withTitle('Penulis');
}