-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace Cone\Bazar\Resources; | ||
|
||
use Cone\Bazar\Models\TaxRate; | ||
use Cone\Root\Fields\Boolean; | ||
use Cone\Root\Fields\ID; | ||
use Cone\Root\Fields\Number; | ||
use Cone\Root\Fields\Text; | ||
use Cone\Root\Resources\Resource; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Http\Request; | ||
|
||
class TaxRateResource extends Resource | ||
{ | ||
/** | ||
* The model class. | ||
*/ | ||
protected string $model = TaxRate::class; | ||
|
||
/** | ||
* The group for the resource. | ||
*/ | ||
protected string $group = 'Shop'; | ||
|
||
/** | ||
* Get the model for the resource. | ||
*/ | ||
public function getModel(): string | ||
{ | ||
return $this->model::getProxiedClass(); | ||
} | ||
|
||
/** | ||
* Define the fields. | ||
*/ | ||
public function fields(Request $request): array | ||
{ | ||
return [ | ||
ID::make(), | ||
|
||
Text::make(__('Name'), 'name') | ||
->rules(['required', 'string', 'max:256']) | ||
->searchable() | ||
->sortable() | ||
->required(), | ||
|
||
Number::make(__('Rate'), 'rate') | ||
->required() | ||
->rules(['required', 'numeric', 'min:0']) | ||
->step(0.1) | ||
->min(0) | ||
->suffix('%') | ||
->format(static function (Request $request, Model $model): string { | ||
return $model->formattedValue; | ||
}), | ||
|
||
Boolean::make(__('Shipping'), 'shipping') | ||
->help(__('If the box is checked, the tax rate is applied for the shipping costs.')) | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace {{ namespace }}Root\Resources; | ||
|
||
use Cone\Bazar\Resources\TaxRateResource as Resource; | ||
use Illuminate\Http\Request; | ||
|
||
class TaxRateResource extends Resource | ||
{ | ||
/** | ||
* Define the fields. | ||
*/ | ||
public function fields(Request $request): array | ||
{ | ||
return array_merge(parent::fields($request), [ | ||
// | ||
]); | ||
} | ||
} |