当前位置: 首页>>代码示例>>PHP>>正文


PHP Company::scopeCompanyables方法代码示例

本文整理汇总了PHP中app\models\Company::scopeCompanyables方法的典型用法代码示例。如果您正苦于以下问题:PHP Company::scopeCompanyables方法的具体用法?PHP Company::scopeCompanyables怎么用?PHP Company::scopeCompanyables使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Company的用法示例。


在下文中一共展示了Company::scopeCompanyables方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getEdit

 /**
  *  Returns a form view to edit a selected asset maintenance.
  *
  * @see AssetMaintenancesController::postEdit() method that stores the data
  * @author  Vincent Sposato <vincent.sposato@gmail.com>
  * @param int $assetMaintenanceId
  * @version v1.0
  * @since [v1.8]
  * @return mixed
  */
 public function getEdit($assetMaintenanceId = null)
 {
     // Check if the asset maintenance exists
     if (is_null($assetMaintenance = AssetMaintenance::find($assetMaintenanceId))) {
         // Redirect to the improvement management page
         return redirect()->to('admin/asset_maintenances')->with('error', trans('admin/asset_maintenances/message.not_found'));
     } elseif (!Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
         return static::getInsufficientPermissionsRedirect();
     }
     if ($assetMaintenance->completion_date == '0000-00-00') {
         $assetMaintenance->completion_date = null;
     }
     if ($assetMaintenance->start_date == '0000-00-00') {
         $assetMaintenance->start_date = null;
     }
     if ($assetMaintenance->cost == '0.00') {
         $assetMaintenance->cost = null;
     }
     // Prepare Improvement Type List
     $assetMaintenanceType = ['' => 'Select an improvement type'] + AssetMaintenance::getImprovementOptions();
     $assets = Company::scopeCompanyables(Asset::with('model', 'assignedUser')->get(), 'assets.company_id')->lists('detailed_name', 'id');
     // Get Supplier List
     $supplier_list = Helper::suppliersList();
     // Render the view
     return View::make('asset_maintenances/edit')->with('asset_list', $assets)->with('selectedAsset', null)->with('supplier_list', $supplier_list)->with('assetMaintenanceType', $assetMaintenanceType)->with('assetMaintenance', $assetMaintenance);
 }
开发者ID:jbirdkerr,项目名称:snipe-it,代码行数:36,代码来源:AssetMaintenancesController.php

示例2: getBulkCheckout

 public function getBulkCheckout()
 {
     // Get the dropdown of users and then pass it to the checkout view
     $users_list = Helper::usersList();
     // Filter out assets that are not deployable.
     $assets = Asset::RTD()->get();
     $assets_list = Company::scopeCompanyables($assets, 'assets.company_id')->lists('detailed_name', 'id')->toArray();
     return View::make('hardware/bulk-checkout')->with('users_list', $users_list)->with('assets_list', $assets_list);
 }
开发者ID:stijni,项目名称:snipe-it,代码行数:9,代码来源:AssetsController.php

示例3: scopeRequestableAssets

 /**
  * Query builder scope for Requestable assets
  *
  * @param  Illuminate\Database\Query\Builder $query Query builder instance
  *
  * @return Illuminate\Database\Query\Builder          Modified query builder
  */
 public function scopeRequestableAssets($query)
 {
     return Company::scopeCompanyables($query->where('requestable', '=', 1))->whereHas('assetstatus', function ($query) {
         $query->where('deployable', '=', 1)->where('pending', '=', 0)->where('archived', '=', 0);
     });
 }
开发者ID:jbirdkerr,项目名称:snipe-it,代码行数:13,代码来源:Asset.php

示例4: getDatatable

 /**
  * Returns the JSON response containing the the consumables data.
  *
  * @author [A. Gianotto] [<snipe@snipe.net>]
  * @see ConsumablesController::getIndex() method that returns the view that consumes the JSON.
  * @since [v1.0]
  * @param int $consumableId
  * @return View
  */
 public function getDatatable()
 {
     $consumables = Company::scopeCompanyables(Consumable::select('consumables.*')->whereNull('consumables.deleted_at')->with('company', 'location', 'category', 'users'));
     if (Input::has('search')) {
         $consumables = $consumables->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;
     }
     $allowed_columns = ['id', 'name', 'order_number', 'min_amt', 'purchase_date', 'purchase_cost', 'companyName', 'category', 'model_no', 'item_no', 'manufacturer'];
     $order = Input::get('order') === 'asc' ? 'asc' : 'desc';
     $sort = in_array(Input::get('sort'), $allowed_columns) ? Input::get('sort') : 'created_at';
     switch ($sort) {
         case 'category':
             $consumables = $consumables->OrderCategory($order);
             break;
         case 'location':
             $consumables = $consumables->OrderLocation($order);
             break;
         case 'manufacturer':
             $consumables = $consumables->OrderManufacturer($order);
             break;
         case 'companyName':
             $consumables = $consumables->OrderCompany($order);
             break;
         default:
             $consumables = $consumables->orderBy($sort, $order);
             break;
     }
     $consumCount = $consumables->count();
     $consumables = $consumables->skip($offset)->take($limit)->get();
     $rows = array();
     foreach ($consumables as $consumable) {
         $actions = '<nobr>';
         if (Gate::allows('consumables.checkout')) {
             $actions .= '<a href="' . route('checkout/consumable', $consumable->id) . '" style="margin-right:5px;" class="btn btn-info btn-sm" ' . ($consumable->numRemaining() > 0 ? '' : ' disabled') . '>' . trans('general.checkout') . '</a>';
         }
         if (Gate::allows('consumables.edit')) {
             $actions .= '<a href="' . route('update/consumable', $consumable->id) . '" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a>';
         }
         if (Gate::allows('consumables.delete')) {
             $actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/consumable', $consumable->id) . '" data-content="' . trans('admin/consumables/message.delete.confirm') . '" data-title="' . trans('general.delete') . ' ' . htmlspecialchars($consumable->name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
         }
         $actions .= '</nobr>';
         $company = $consumable->company;
         $rows[] = array('id' => $consumable->id, 'name' => (string) link_to('admin/consumables/' . $consumable->id . '/view', e($consumable->name)), 'location' => $consumable->location ? e($consumable->location->name) : '', 'min_amt' => e($consumable->min_amt), 'qty' => e($consumable->qty), 'manufacturer' => $consumable->manufacturer ? e($consumable->manufacturer->name) : '', 'model_no' => e($consumable->model_no), 'item_no' => e($consumable->item_no), 'category' => $consumable->category ? e($consumable->category->name) : 'Missing category', 'order_number' => e($consumable->order_number), 'purchase_date' => e($consumable->purchase_date), 'purchase_cost' => $consumable->purchase_cost != '' ? number_format($consumable->purchase_cost, 2) : '', 'numRemaining' => $consumable->numRemaining(), 'actions' => $actions, 'companyName' => is_null($company) ? '' : e($company->name));
     }
     $data = array('total' => $consumCount, 'rows' => $rows);
     return $data;
 }
开发者ID:jbirdkerr,项目名称:snipe-it,代码行数:66,代码来源:ConsumablesController.php

示例5: getDatatable

 /**
  * Generates a JSON response to populate the licence index datatables.
  *
  * @author [A. Gianotto] [<snipe@snipe.net>]
  * @see LicensesController::getIndex() method that provides the view
  * @since [v1.0]
  * @return String JSON
  */
 public function getDatatable()
 {
     $licenses = Company::scopeCompanyables(License::with('company'));
     if (Input::has('search')) {
         $licenses = $licenses->TextSearch(Input::get('search'));
     }
     $allowed_columns = ['id', 'name', 'purchase_cost', 'expiration_date', 'purchase_order', 'order_number', 'notes', 'purchase_date', 'serial'];
     $order = Input::get('order') === 'asc' ? 'asc' : 'desc';
     $sort = in_array(Input::get('sort'), $allowed_columns) ? e(Input::get('sort')) : 'created_at';
     $licenses = $licenses->orderBy($sort, $order);
     $licenseCount = $licenses->count();
     $licenses = $licenses->skip(Input::get('offset'))->take(Input::get('limit'))->get();
     $rows = array();
     foreach ($licenses as $license) {
         $actions = '<span style="white-space: nowrap;">';
         if (Gate::allows('licenses.checkout')) {
             $actions .= '<a href="' . route('freecheckout/license', $license->id) . '" class="btn btn-primary btn-sm' . ($license->remaincount() > 0 ? '' : ' disabled') . '" style="margin-right:5px;">' . trans('general.checkout') . '</a> ';
         }
         if (Gate::allows('licenses.create')) {
             $actions .= '<a href="' . route('clone/license', $license->id) . '" class="btn btn-info btn-sm" style="margin-right:5px;" title="Clone asset"><i class="fa fa-files-o"></i></a>';
         }
         if (Gate::allows('licenses.edit')) {
             $actions .= '<a href="' . route('update/license', $license->id) . '" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a>';
         }
         if (Gate::allows('licenses.delete')) {
             $actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/license', $license->id) . '" data-content="' . trans('admin/licenses/message.delete.confirm') . '" data-title="' . trans('general.delete') . ' ' . htmlspecialchars($license->name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
         }
         $actions .= '</span>';
         $rows[] = array('id' => $license->id, 'name' => (string) link_to('/admin/licenses/' . $license->id . '/view', $license->name), 'serial' => (string) link_to('/admin/licenses/' . $license->id . '/view', mb_strimwidth($license->serial, 0, 50, "...")), 'totalSeats' => $license->totalSeatsByLicenseID(), 'remaining' => $license->remaincount(), 'license_name' => e($license->license_name), 'license_email' => e($license->license_email), 'purchase_date' => $license->purchase_date ? $license->purchase_date : '', 'expiration_date' => $license->expiration_date ? $license->expiration_date : '', 'purchase_cost' => $license->purchase_cost ? number_format($license->purchase_cost, 2) : '', 'purchase_order' => $license->purchase_order ? e($license->purchase_order) : '', 'order_number' => $license->order_number ? e($license->order_number) : '', 'notes' => $license->notes ? e($license->notes) : '', 'actions' => $actions, 'companyName' => is_null($license->company) ? '' : e($license->company->name));
     }
     $data = array('total' => $licenseCount, 'rows' => $rows);
     return $data;
 }
开发者ID:jbirdkerr,项目名称:snipe-it,代码行数:41,代码来源:LicensesController.php

示例6: getDatatable

 /**
  * Return JSON response with a list of user details for the getIndex() view.
  *
  * @author [A. Gianotto] [<snipe@snipe.net>]
  * @since [v1.6]
  * @see UsersController::getIndex() method that consumed this JSON response
  * @return string JSON
  */
 public function getDatatable(Request $request, $status = null)
 {
     if (Input::has('offset')) {
         $offset = e(Input::get('offset'));
     } else {
         $offset = 0;
     }
     if (Input::has('limit')) {
         $limit = e(Input::get('limit'));
     } else {
         $limit = 50;
     }
     if (Input::get('sort') == 'name') {
         $sort = 'first_name';
     } else {
         $sort = e(Input::get('sort'));
     }
     $users = User::select(array('users.id', 'users.employee_num', 'users.email', 'users.username', 'users.location_id', 'users.manager_id', 'users.first_name', 'users.last_name', 'users.created_at', 'users.notes', 'users.company_id', 'users.deleted_at', 'users.activated'))->with('assets', 'accessories', 'consumables', 'licenses', 'manager', 'groups', 'userloc', 'company', 'throttle');
     $users = Company::scopeCompanyables($users);
     switch ($status) {
         case 'deleted':
             $users = $users->withTrashed()->Deleted();
             break;
     }
     if (Input::has('search')) {
         $users = $users->TextSearch(Input::get('search'));
     }
     $order = Input::get('order') === 'asc' ? 'asc' : 'desc';
     switch (Input::get('sort')) {
         case 'manager':
             $users = $users->OrderManager($order);
             break;
         case 'location':
             $users = $users->OrderLocation($order);
             break;
         default:
             $allowed_columns = ['last_name', 'first_name', 'email', 'username', 'employee_num', 'assets', 'accessories', 'consumables', 'licenses', 'groups', 'activated', 'created_at'];
             $sort = in_array($sort, $allowed_columns) ? $sort : 'first_name';
             $users = $users->orderBy($sort, $order);
             break;
     }
     $userCount = $users->count();
     $users = $users->skip($offset)->take($limit)->get();
     $rows = array();
     foreach ($users as $user) {
         $group_names = '';
         $inout = '';
         $actions = '<nobr>';
         foreach ($user->groups as $group) {
             $group_names .= '<a href="' . config('app.url') . '/admin/groups/' . $group->id . '/edit" class="label  label-default">' . $group->name . '</a> ';
         }
         if (!is_null($user->deleted_at)) {
             if (Gate::allows('users.delete')) {
                 $actions .= '<a href="' . route('restore/user', $user->id) . '" class="btn btn-warning btn-sm"><i class="fa fa-share icon-white"></i></a> ';
             }
         } else {
             if (Gate::allows('users.delete')) {
                 if ($user->accountStatus() == 'suspended') {
                     $actions .= '<a href="' . route('unsuspend/user', $user->id) . '" class="btn btn-default btn-sm"><span class="fa fa-clock-o"></span></a> ';
                 }
             }
             if (Gate::allows('users.edit')) {
                 $actions .= '<a href="' . route('update/user', $user->id) . '" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a> ';
                 $actions .= '<a href="' . route('clone/user', $user->id) . '" class="btn btn-info btn-sm"><i class="fa fa-clone"></i></a>';
             }
             if (Gate::allows('users.delete')) {
                 if (Auth::user()->id !== $user->id && !config('app.lock_passwords')) {
                     $actions .= '<a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="' . route('delete/user', $user->id) . '" data-content="Are you sure you wish to delete this user?" data-title="Delete ' . htmlspecialchars($user->first_name) . '?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a> ';
                 } else {
                     $actions .= ' <span class="btn delete-asset btn-danger btn-sm disabled"><i class="fa fa-trash icon-white"></i></span>';
                 }
             } else {
                 $actions .= 'foo';
             }
         }
         $actions .= '</nobr>';
         $rows[] = array('id' => $user->id, 'checkbox' => $status != 'deleted' ? '<div class="text-center hidden-xs hidden-sm"><input type="checkbox" name="edit_user[' . e($user->id) . ']" class="one_required"></div>' : '', 'name' => '<a title="' . e($user->fullName()) . '" href="../admin/users/' . e($user->id) . '/view">' . e($user->fullName()) . '</a>', 'email' => $user->email != '' ? '<a href="mailto:' . e($user->email) . '" class="hidden-md hidden-lg">' . e($user->email) . '</a>' . '<a href="mailto:' . e($user->email) . '" class="hidden-xs hidden-sm"><i class="fa fa-envelope"></i></a>' . '</span>' : '', 'username' => e($user->username), 'location' => $user->userloc ? e($user->userloc->name) : '', 'manager' => $user->manager ? '<a title="' . e($user->manager->fullName()) . '" href="users/' . e($user->manager->id) . '/view">' . e($user->manager->fullName()) . '</a>' : '', 'assets' => $user->assets->count(), 'employee_num' => e($user->employee_num), 'licenses' => $user->licenses->count(), 'accessories' => $user->accessories->count(), 'consumables' => $user->consumables->count(), 'groups' => $group_names, 'notes' => e($user->notes), 'created_at' => $user->created_at != '' ? e($user->created_at->format('F j, Y h:iA')) : '', 'activated' => $user->activated == '1' ? '<i class="fa fa-check"></i>' : '<i class="fa fa-times"></i>', 'actions' => $actions ? $actions : '', 'companyName' => is_null($user->company) ? '' : e($user->company->name));
     }
     $data = array('total' => $userCount, 'rows' => $rows);
     return $data;
 }
开发者ID:stijni,项目名称:snipe-it,代码行数:89,代码来源:UsersController.php

示例7: detailedAssetList

 public static function detailedAssetList()
 {
     $assets = array('' => trans('general.select_asset')) + Company::scopeCompanyables(Asset::all(), 'assets.company_id')->lists('detailed_name', 'id')->toArray();
     return $assets;
 }
开发者ID:stijni,项目名称:snipe-it,代码行数:5,代码来源:Helper.php

示例8: apply

 /**
  * Apply the scope to a given Eloquent query builder.
  *
  * @param  \Illuminate\Database\Eloquent\Builder  $builder
  * @return void
  */
 public function apply(Builder $builder, Model $model)
 {
     return Company::scopeCompanyables($builder);
 }
开发者ID:dmeltzer,项目名称:snipe-it,代码行数:10,代码来源:CompanyableScope.php


注:本文中的app\models\Company::scopeCompanyables方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。