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


PHP Company::getIdForCurrentUser方法代码示例

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


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

示例1: postEdit

 /**
  * Validate and process asset edit form.
  *
  * @author [A. Gianotto] [<snipe@snipe.net>]
  * @param int $assetId
  * @since [v1.0]
  * @return Redirect
  */
 public function postEdit(AssetRequest $request, $assetId = null)
 {
     // Check if the asset exists
     if (!($asset = Asset::find($assetId))) {
         // Redirect to the asset management page with error
         return redirect()->to('hardware')->with('error', trans('admin/hardware/message.does_not_exist'));
     } elseif (!Company::isCurrentUserHasAccess($asset)) {
         return redirect()->to('hardware')->with('error', trans('general.insufficient_permissions'));
     }
     if ($request->has('status_id')) {
         $asset->status_id = e($request->input('status_id'));
     } else {
         $asset->status_id = null;
     }
     if ($request->has('warranty_months')) {
         $asset->warranty_months = e($request->input('warranty_months'));
     } else {
         $asset->warranty_months = null;
     }
     if ($request->has('purchase_cost')) {
         $asset->purchase_cost = e(Helper::formatCurrencyOutput($request->input('purchase_cost')));
     } else {
         $asset->purchase_cost = null;
     }
     if ($request->has('purchase_date')) {
         $asset->purchase_date = e($request->input('purchase_date'));
     } else {
         $asset->purchase_date = null;
     }
     if ($request->has('supplier_id')) {
         $asset->supplier_id = e($request->input('supplier_id'));
     } else {
         $asset->supplier_id = null;
     }
     // If the box isn't checked, it's not in the request at all.
     $asset->requestable = $request->has('requestable');
     if ($request->has('rtd_location_id')) {
         $asset->rtd_location_id = e($request->input('rtd_location_id'));
     } else {
         $asset->rtd_location_id = null;
     }
     if ($request->has('image_delete')) {
         unlink(public_path() . '/uploads/assets/' . $asset->image);
         $asset->image = '';
     }
     // Update the asset data
     $asset->name = e($request->input('name'));
     $asset->serial = e($request->input('serial'));
     $asset->company_id = Company::getIdForCurrentUser(e($request->input('company_id')));
     $asset->model_id = e($request->input('model_id'));
     $asset->order_number = e($request->input('order_number'));
     $asset->asset_tag = e($request->input('asset_tag'));
     $asset->notes = e($request->input('notes'));
     $asset->physical = '1';
     // Update the image
     if (Input::has('image')) {
         $image = $request->input('image');
         // See postCreate for more explaination of the following.
         $header = explode(';', $image, 2)[0];
         $extension = substr($header, strpos($header, '/') + 1);
         $image = substr($image, strpos($image, ',') + 1);
         $directory = public_path('uploads/assets/');
         // Check if the uploads directory exists.  If not, try to create it.
         if (!file_exists($directory)) {
             mkdir($directory, 0755);
         }
         $file_name = str_random(25) . "." . $extension;
         $path = public_path('uploads/assets/' . $file_name);
         try {
             Image::make($image)->resize(500, 500, function ($constraint) {
                 $constraint->aspectRatio();
                 $constraint->upsize();
             })->save($path);
             $asset->image = $file_name;
         } catch (\Exception $e) {
             \Input::flash();
             $messageBag = new \Illuminate\Support\MessageBag();
             $messageBag->add('image', $e->getMessage());
             \Session()->flash('errors', \Session::get('errors', new \Illuminate\Support\ViewErrorBag())->put('default', $messageBag));
             return response()->json(['image' => $e->getMessage()], 422);
         }
         $asset->image = $file_name;
     }
     // Update custom fields in the database.
     // Validation for these fields is handlded through the AssetRequest form request
     // FIXME: No idea why this is returning a Builder error on db_column_name.
     // Need to investigate and fix. Using static method for now.
     $model = AssetModel::find($request->get('model_id'));
     if ($model->fieldset) {
         foreach ($model->fieldset->fields as $field) {
             if ($field->field_encrypted == '1') {
                 if (Gate::allows('admin')) {
//.........这里部分代码省略.........
开发者ID:stijni,项目名称:snipe-it,代码行数:101,代码来源:AssetsController.php

示例2: postEdit

 /**
  * Returns a form view to edit a consumable.
  *
  * @author [A. Gianotto] [<snipe@snipe.net>]
  * @param  int $consumableId
  * @see ConsumablesController::getEdit() method that stores the form data.
  * @since [v1.0]
  * @return Redirect
  */
 public function postEdit($consumableId = null)
 {
     if (is_null($consumable = Consumable::find($consumableId))) {
         return redirect()->to('admin/consumables')->with('error', trans('admin/consumables/message.does_not_exist'));
     } elseif (!Company::isCurrentUserHasAccess($consumable)) {
         return redirect()->to('admin/consumables')->with('error', trans('general.insufficient_permissions'));
     }
     $consumable->name = e(Input::get('name'));
     $consumable->category_id = e(Input::get('category_id'));
     $consumable->location_id = e(Input::get('location_id'));
     $consumable->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
     $consumable->order_number = e(Input::get('order_number'));
     $consumable->min_amt = e(Input::get('min_amt'));
     $consumable->manufacturer_id = e(Input::get('manufacturer_id'));
     $consumable->model_no = e(Input::get('model_no'));
     $consumable->item_no = e(Input::get('item_no'));
     if (e(Input::get('purchase_date')) == '') {
         $consumable->purchase_date = null;
     } else {
         $consumable->purchase_date = e(Input::get('purchase_date'));
     }
     if (e(Input::get('purchase_cost')) == '0.00') {
         $consumable->purchase_cost = null;
     } else {
         $consumable->purchase_cost = e(Input::get('purchase_cost'));
     }
     $consumable->qty = e(Input::get('qty'));
     if ($consumable->save()) {
         return redirect()->to("admin/consumables")->with('success', trans('admin/consumables/message.update.success'));
     }
     return redirect()->back()->withInput()->withErrors($consumable->getErrors());
 }
开发者ID:jbirdkerr,项目名称:snipe-it,代码行数:41,代码来源:ConsumablesController.php

示例3: postEdit

 /**
  * Validates and stores the license form data submitted from the edit
  * license form.
  *
  * @author [A. Gianotto] [<snipe@snipe.net>]
  * @see LicensesController::getEdit() method that provides the form view
  * @since [v1.0]
  * @param int $licenseId
  * @return Redirect
  */
 public function postEdit($licenseId = null)
 {
     // Check if the license exists
     if (is_null($license = License::find($licenseId))) {
         // Redirect to the blogs management page
         return redirect()->to('admin/licenses')->with('error', trans('admin/licenses/message.does_not_exist'));
     } elseif (!Company::isCurrentUserHasAccess($license)) {
         return redirect()->to('admin/licenses')->with('error', trans('general.insufficient_permissions'));
     }
     // Update the license data
     $license->name = e(Input::get('name'));
     $license->serial = e(Input::get('serial'));
     $license->license_email = e(Input::get('license_email'));
     $license->license_name = e(Input::get('license_name'));
     $license->notes = e(Input::get('notes'));
     $license->order_number = e(Input::get('order_number'));
     $license->depreciation_id = e(Input::get('depreciation_id'));
     $license->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
     $license->purchase_order = e(Input::get('purchase_order'));
     $license->maintained = e(Input::get('maintained'));
     $license->reassignable = e(Input::get('reassignable'));
     if (e(Input::get('supplier_id')) == '') {
         $license->supplier_id = null;
     } else {
         $license->supplier_id = e(Input::get('supplier_id'));
     }
     // Update the asset data
     if (e(Input::get('purchase_date')) == '') {
         $license->purchase_date = null;
     } else {
         $license->purchase_date = e(Input::get('purchase_date'));
     }
     if (e(Input::get('expiration_date')) == '') {
         $license->expiration_date = null;
     } else {
         $license->expiration_date = e(Input::get('expiration_date'));
     }
     if (e(Input::get('termination_date')) == '') {
         $license->termination_date = null;
     } else {
         $license->termination_date = e(Input::get('termination_date'));
     }
     if (e(Input::get('purchase_cost')) == '') {
         $license->purchase_cost = null;
     } else {
         $license->purchase_cost = e(Input::get('purchase_cost'));
         //$license->purchase_cost = e(Input::get('purchase_cost'));
     }
     if (e(Input::get('maintained')) == '') {
         $license->maintained = 0;
     } else {
         $license->maintained = e(Input::get('maintained'));
     }
     if (e(Input::get('reassignable')) == '') {
         $license->reassignable = 0;
     } else {
         $license->reassignable = e(Input::get('reassignable'));
     }
     if (e(Input::get('purchase_order')) == '') {
         $license->purchase_order = '';
     } else {
         $license->purchase_order = e(Input::get('purchase_order'));
     }
     //Are we changing the total number of seats?
     if ($license->seats != e(Input::get('seats'))) {
         //Determine how many seats we are dealing with
         $difference = e(Input::get('seats')) - $license->licenseseats()->count();
         if ($difference < 0) {
             //Filter out any license which have a user attached;
             $seats = $license->licenseseats->filter(function ($seat) {
                 return is_null($seat->user);
             });
             //If the remaining collection is as large or larger than the number of seats we want to delete
             if ($seats->count() >= abs($difference)) {
                 for ($i = 1; $i <= abs($difference); $i++) {
                     //Delete the appropriate number of seats
                     $seats->pop()->delete();
                 }
                 //Log the deletion of seats to the log
                 $logaction = new Actionlog();
                 $logaction->asset_id = $license->id;
                 $logaction->asset_type = 'software';
                 $logaction->user_id = Auth::user()->id;
                 $logaction->note = abs($difference) . " seats";
                 $logaction->checkedout_to = null;
                 $log = $logaction->logaction('delete seats');
             } else {
                 // Redirect to the license edit page
                 return redirect()->to("admin/licenses/{$licenseId}/edit")->with('error', trans('admin/licenses/message.assoc_users'));
             }
//.........这里部分代码省略.........
开发者ID:jbirdkerr,项目名称:snipe-it,代码行数:101,代码来源:LicensesController.php

示例4: postEdit

 /**
  * Return a view to edit a component.
  *
  * @author [A. Gianotto] [<snipe@snipe.net>]
  * @see ComponentsController::getEdit() method presents the form.
  * @param int $componentId
  * @since [v3.0]
  * @return Redirect
  */
 public function postEdit($componentId = null)
 {
     // Check if the blog post exists
     if (is_null($component = Component::find($componentId))) {
         // Redirect to the blogs management page
         return redirect()->to('admin/components')->with('error', trans('admin/components/message.does_not_exist'));
     } elseif (!Company::isCurrentUserHasAccess($component)) {
         return redirect()->to('admin/components')->with('error', trans('general.insufficient_permissions'));
     }
     // Update the component data
     $component->name = e(Input::get('name'));
     $component->category_id = e(Input::get('category_id'));
     $component->location_id = e(Input::get('location_id'));
     $component->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
     $component->order_number = e(Input::get('order_number'));
     $component->min_amt = e(Input::get('min_amt'));
     if (e(Input::get('purchase_date')) == '') {
         $component->purchase_date = null;
     } else {
         $component->purchase_date = e(Input::get('purchase_date'));
     }
     if (e(Input::get('purchase_cost')) == '0.00') {
         $component->purchase_cost = null;
     } else {
         $component->purchase_cost = e(Input::get('purchase_cost'));
     }
     $component->total_qty = e(Input::get('total_qty'));
     // Was the component created?
     if ($component->save()) {
         // Redirect to the new component page
         return redirect()->to("admin/components")->with('success', trans('admin/components/message.update.success'));
     }
     return redirect()->back()->withInput()->withErrors($component->getErrors());
 }
开发者ID:stijni,项目名称:snipe-it,代码行数:43,代码来源:ComponentsController.php

示例5: postEdit

 /**
  * Save edited Accessory from form post
  *
  * @author [A. Gianotto] [<snipe@snipe.net>]
  * @param  int  $accessoryId
  * @return Redirect
  */
 public function postEdit(Request $request, $accessoryId = null)
 {
     // Check if the accessory exists
     if (is_null($accessory = Accessory::find($accessoryId))) {
         // Redirect to the accessory index page
         return redirect()->to('admin/accessories')->with('error', trans('admin/accessories/message.does_not_exist'));
     } elseif (!Company::isCurrentUserHasAccess($accessory)) {
         return redirect()->to('admin/accessories')->with('error', trans('general.insufficient_permissions'));
     }
     // Update the accessory data
     $accessory->name = e(Input::get('name'));
     if (e(Input::get('location_id')) == '') {
         $accessory->location_id = null;
     } else {
         $accessory->location_id = e(Input::get('location_id'));
     }
     $accessory->min_amt = e(Input::get('min_amt'));
     $accessory->category_id = e(Input::get('category_id'));
     $accessory->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
     $accessory->manufacturer_id = e(Input::get('manufacturer_id'));
     $accessory->order_number = e(Input::get('order_number'));
     if (e(Input::get('purchase_date')) == '') {
         $accessory->purchase_date = null;
     } else {
         $accessory->purchase_date = e(Input::get('purchase_date'));
     }
     if (e(Input::get('purchase_cost')) == '0.00') {
         $accessory->purchase_cost = null;
     } else {
         $accessory->purchase_cost = e(Input::get('purchase_cost'));
     }
     $accessory->qty = e(Input::get('qty'));
     // Was the accessory updated?
     if ($accessory->save()) {
         // Redirect to the updated accessory page
         return redirect()->to("admin/accessories")->with('success', trans('admin/accessories/message.update.success'));
     }
     return redirect()->back()->withInput()->withErrors($accessory->getErrors());
 }
开发者ID:stijni,项目名称:snipe-it,代码行数:46,代码来源:AccessoriesController.php


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