Currency rate
This commit is contained in:
@@ -4,6 +4,8 @@ namespace App\Nova\Resources;
|
||||
|
||||
use App\Models\CurrencyRate as ModelsCurrencyRate;
|
||||
use App\Nova\Resource;
|
||||
use App\Nova\Resources\CurrencyRate\CurrencyRateAuth;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
@@ -13,6 +15,8 @@ use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
|
||||
class CurrencyRate extends Resource
|
||||
{
|
||||
use CurrencyRateAuth;
|
||||
|
||||
/**
|
||||
* The model the resource corresponds to.
|
||||
*
|
||||
@@ -37,33 +41,11 @@ class CurrencyRate extends Resource
|
||||
];
|
||||
|
||||
/**
|
||||
* Determine if the given resource is authorizable.
|
||||
*
|
||||
* @return bool
|
||||
* Get the displayable label of the resource.
|
||||
*/
|
||||
public static function authorizable()
|
||||
public static function label(): string
|
||||
{
|
||||
if (auth()->user()->isSystemUser()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// disables
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the resource should be available for the given request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return bool
|
||||
*/
|
||||
public static function authorizedToViewAny(Request $request)
|
||||
{
|
||||
if (auth()->user()->isSystemUser()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return __('Currency rate');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
79
app/Nova/Resources/CurrencyRate/CurrencyRateAuth.php
Normal file
79
app/Nova/Resources/CurrencyRate/CurrencyRateAuth.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova\Resources\CurrencyRate;
|
||||
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
trait CurrencyRateAuth
|
||||
{
|
||||
/** View */
|
||||
public function authorizeToView(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isSystemUser()) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new AuthorizationException();
|
||||
}
|
||||
|
||||
/** Edit button */
|
||||
public function authorizedToUpdate(Request $request): bool
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isSystemUser()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Update */
|
||||
public function authorizeToUpdate(Request $request): void
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isSystemUser()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->resource->user_id == auth()->id()) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new AuthorizationException();
|
||||
}
|
||||
|
||||
/** Delete button */
|
||||
public function authorizedToDelete(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isMe()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Delete */
|
||||
public function authorizeToDelete(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->isMe()) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new AuthorizationException();
|
||||
}
|
||||
|
||||
/** Force delete */
|
||||
public function authorizedToForceDelete(Request $request)
|
||||
{
|
||||
throw_unless(auth()->user()->isMe(), AuthorizationException::class);
|
||||
}
|
||||
}
|
||||
@@ -132,10 +132,6 @@ class User extends Resource
|
||||
|
||||
BelongsToMany::make(__('Branches'), 'branches', Branch::class)
|
||||
->canSeeWhen('isAdmin', $this),
|
||||
|
||||
HasMany::make(__('Loan order'), 'loanOrders', LoanOrder::class),
|
||||
|
||||
HasMany::make(__('Card order'), 'cardOrders', CardOrder::class),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -322,6 +322,7 @@
|
||||
"Loan Card": "Karz karty",
|
||||
"Send payment": "Tölegi geçir",
|
||||
"Currencies": "Walýutalar",
|
||||
"Currency rate": "Walýuta kursy",
|
||||
"Passport number": "Pasport nomeri",
|
||||
"Fetch loan history": "Karz taryhyny görmek",
|
||||
"Online payment": "Onlaýn töleg",
|
||||
|
||||
Reference in New Issue
Block a user