Set purchase cost to null if user has no permission to view the price

This commit is contained in:
Cas de Reuver 2024-12-09 14:01:55 +01:00
parent 43d66a8fcc
commit ef66188041
No known key found for this signature in database

View file

@ -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,13 @@ class SnipeModel extends Model
{
return $this->name;
}
public function getPurchaseCostAttribute($value)
{
if (Auth::check() && !Auth::user()->can('self.view_purchase_cost')) {
return null;
}
return $value;
}
}