mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Merge 94ced12d56
into c9f55bfd94
This commit is contained in:
commit
26ea0f78be
|
@ -4,6 +4,7 @@ namespace App\Models;
|
|||
|
||||
use App\Helpers\Helper;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class SnipeModel extends Model
|
||||
{
|
||||
|
@ -160,4 +161,20 @@ class SnipeModel extends Model
|
|||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the user is allowed to view the purchase cost of the specific item.
|
||||
* If the user doesn't have permissions, set the value to null so it will be hidden.
|
||||
*
|
||||
* @param $value
|
||||
* @return null|float The purchase cost
|
||||
*/
|
||||
public function getPurchaseCostAttribute($value)
|
||||
{
|
||||
if (Auth::check() && !Auth::user()->can('viewPurchaseCost', $this)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,4 +160,15 @@ abstract class SnipePermissionsPolicy
|
|||
{
|
||||
return $user->hasAccess($this->columnName().'.edit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can view the purchase cost.
|
||||
*
|
||||
* @param \App\Models\User $user
|
||||
* @return mixed
|
||||
*/
|
||||
public function viewPurchaseCost(User $user)
|
||||
{
|
||||
return $user->hasAccess($this->columnName().'.view.purchase_cost');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,6 +113,12 @@ return [
|
|||
'display' => true,
|
||||
],
|
||||
|
||||
[
|
||||
'permission' => 'assets.view.purchase_cost',
|
||||
'label' => 'View and Modify Purchase Cost',
|
||||
'note' => '',
|
||||
'display' => true,
|
||||
],
|
||||
],
|
||||
|
||||
'Accessories' => [
|
||||
|
@ -159,6 +165,13 @@ return [
|
|||
'display' => true,
|
||||
],
|
||||
|
||||
[
|
||||
'permission' => 'accesories.view.purchase_cost',
|
||||
'label' => 'View and Modify Purchase Cost',
|
||||
'note' => '',
|
||||
'display' => true,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
'Consumables' => [
|
||||
|
@ -198,6 +211,13 @@ return [
|
|||
'note' => '',
|
||||
'display' => true,
|
||||
],
|
||||
|
||||
[
|
||||
'permission' => 'consumables.view.purchase_cost',
|
||||
'label' => 'View and Modify Purchase Cost',
|
||||
'note' => '',
|
||||
'display' => true,
|
||||
],
|
||||
],
|
||||
|
||||
|
||||
|
@ -244,6 +264,13 @@ return [
|
|||
'note' => '',
|
||||
'display' => true,
|
||||
],
|
||||
|
||||
[
|
||||
'permission' => 'licenses.view.purchase_cost',
|
||||
'label' => 'View and Modify Purchase Cost',
|
||||
'note' => '',
|
||||
'display' => true,
|
||||
],
|
||||
],
|
||||
|
||||
|
||||
|
@ -291,6 +318,13 @@ return [
|
|||
'display' => true,
|
||||
],
|
||||
|
||||
[
|
||||
'permission' => 'components.view.purchase_cost',
|
||||
'label' => 'View and Modify Purchase Cost',
|
||||
'note' => '',
|
||||
'display' => true,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
'Kits' => [
|
||||
|
|
Loading…
Reference in a new issue