diff --git a/app/Http/Requests/Activity/ShowActivityRequest.php b/app/Http/Requests/Activity/ShowActivityRequest.php index 24dec8468..d7c745cb5 100644 --- a/app/Http/Requests/Activity/ShowActivityRequest.php +++ b/app/Http/Requests/Activity/ShowActivityRequest.php @@ -23,7 +23,7 @@ class ShowActivityRequest extends Request */ public function authorize() : bool { - return auth()->user()->isAdmin(); - // return auth()->user()->can('view', Activity::class); + // return auth()->user()->isAdmin(); + return auth()->user()->can('view', Activity::class); } } diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 442621808..5c2af53d3 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -375,18 +375,4 @@ class Activity extends StaticModel return $this->belongsTo(Company::class); } -// /** -// * @return mixed -// */ -// public function resolveRouteBinding($value, $field = null) -// { -// if (is_numeric($value)) { -// throw new ModelNotFoundException("Record with value {$value} not found"); -// } - -// return $this -// //->withTrashed() -// ->where('id', $this->decodePrimaryKey($value))->firstOrFail(); -// } - } \ No newline at end of file diff --git a/app/Models/ClientGatewayToken.php b/app/Models/ClientGatewayToken.php index 50f616398..5efcea44a 100644 --- a/app/Models/ClientGatewayToken.php +++ b/app/Models/ClientGatewayToken.php @@ -69,17 +69,5 @@ class ClientGatewayToken extends BaseModel { return $this->belongsTo(User::class)->withTrashed(); } - - // /** - // * Retrieve the model for a bound value. - // * - // * @param mixed $value - // * @param null $field - // * @return Model|null - // */ - // public function resolveRouteBinding($value, $field = null) - // { - // return $this - // ->where('id', $this->decodePrimaryKey($value))->firstOrFail(); - // } + } diff --git a/app/Models/CompanyGateway.php b/app/Models/CompanyGateway.php index b5c26fd69..a31dc1746 100644 --- a/app/Models/CompanyGateway.php +++ b/app/Models/CompanyGateway.php @@ -412,12 +412,4 @@ class CompanyGateway extends BaseModel return route('payment_webhook', ['company_key' => $this->company->company_key, 'company_gateway_id' => $this->hashed_id]); } - // public function resolveRouteBinding($value, $field = null) - // { - - // return $this - // ->where('id', $this->decodePrimaryKey($value))->withTrashed()->firstOrFail(); - // } - - } diff --git a/app/Models/Currency.php b/app/Models/Currency.php index 6a1ae1d5c..2da76e654 100644 --- a/app/Models/Currency.php +++ b/app/Models/Currency.php @@ -23,7 +23,6 @@ class Currency extends StaticModel 'updated_at' => 'timestamp', 'created_at' => 'timestamp', 'deleted_at' => 'timestamp', - //'precision' => 'string', 'precision' => 'integer', ]; } diff --git a/app/Models/GroupSetting.php b/app/Models/GroupSetting.php index 539dc9b8f..b465c8a03 100644 --- a/app/Models/GroupSetting.php +++ b/app/Models/GroupSetting.php @@ -14,14 +14,13 @@ namespace App\Models; use App\Utils\Traits\MakesHash; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException; class GroupSetting extends StaticModel { use MakesHash; use SoftDeletes; - //public $timestamps = false; - protected $casts = [ 'settings' => 'object', 'updated_at' => 'timestamp', @@ -65,4 +64,25 @@ class GroupSetting extends StaticModel return $this->morphMany(Document::class, 'documentable'); } + /** + * Retrieve the model for a bound value. + * + * @param mixed $value + * @param null $field + * @return Model|null + */ + public function resolveRouteBinding($value, $field = null) + { + + if (is_numeric($value)) { + throw new ModelNotFoundException("Record with value {$value} not found"); + } + + return $this + ->withTrashed() + ->company() + ->where('id', $this->decodePrimaryKey($value))->firstOrFail(); + + } } + diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 12c90bbec..32a3e2cf3 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -292,14 +292,6 @@ class Payment extends BaseModel return new PaymentService($this); } - - // public function resolveRouteBinding($value, $field = null) - // { - // return $this - // ->withTrashed() - // ->where('id', $this->decodePrimaryKey($value))->firstOrFail(); - // } - public function refund(array $data) :self { return $this->service()->refundPayment($data); diff --git a/app/Models/StaticModel.php b/app/Models/StaticModel.php index f20b97ff1..5f5b9df0b 100644 --- a/app/Models/StaticModel.php +++ b/app/Models/StaticModel.php @@ -57,8 +57,7 @@ class StaticModel extends Model } return $this - ->withTrashed() - ->company() ->where('id', $this->decodePrimaryKey($value))->firstOrFail(); + } }