Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Nov 24, 2023
1 parent d2dbc8c commit 6711823
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/Fields/Transactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Cone\Root\Fields\Number;
use Cone\Root\Fields\Select;
use Cone\Root\Fields\Text;
use Cone\Root\Fields\URL;
use Illuminate\Http\Request;
use Illuminate\Support\Str;

Expand Down Expand Up @@ -61,6 +62,10 @@ public function fields(Request $request): array

Text::make(__('Key'), 'key'),

URL::make(__('URL'), static function (Request $request, Transaction $transaction): ?string {
return $transaction->url;
}),

Date::make(__('Completed At'), 'completed_at')
->withTime(),
];
Expand Down
4 changes: 2 additions & 2 deletions src/Models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected static function newFactory(): Factory
/**
* Get the available order statuses.
*/
public static function statuses(): array
public static function getStatuses(): array
{
return [
static::PENDING => __('Pending'),
Expand Down Expand Up @@ -174,7 +174,7 @@ protected function statusName(): Attribute
{
return new Attribute(
get: static function (mixed $value, array $attributes): string {
return static::statuses()[$attributes['status']] ?? $attributes['status'];
return static::getStatuses()[$attributes['status']] ?? $attributes['status'];
}
);
}
Expand Down
11 changes: 9 additions & 2 deletions src/Resources/OrderResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Cone\Bazar\Fields\Transactions;
use Cone\Bazar\Models\Order;
use Cone\Root\Fields\BelongsTo;
use Cone\Root\Fields\Date;
use Cone\Root\Fields\ID;
use Cone\Root\Fields\Select;
use Cone\Root\Fields\Text;
Expand Down Expand Up @@ -36,7 +37,8 @@ public function fields(Request $request): array
ID::make(),

BelongsTo::make(__('Customer'), 'user')
->display('name'),
->display('name')
->sortable(column: 'name'),

Text::make(__('Total'), static function (Request $request, Order $model): string {
return $model->formattedTotal;
Expand All @@ -46,7 +48,12 @@ public function fields(Request $request): array
->options(Bazar::getCurrencies())
->hiddenOn(['index']),

// Select::make(__('Status'), 'status)->options([]),
Select::make(__('Status'), 'status')
->options(Order::getStatuses()),

Date::make(__('Created At'), 'created_at')
->withTime()
->sortable(),

Items::make(),

Expand Down
1 change: 0 additions & 1 deletion src/Resources/ProductResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Cone\Bazar\Models\Product;
use Cone\Root\Fields\BelongsToMany;
use Cone\Root\Fields\Editor;
use Cone\Root\Fields\HasMany;
use Cone\Root\Fields\ID;
use Cone\Root\Fields\Media;
use Cone\Root\Fields\Meta;
Expand Down

0 comments on commit 6711823

Please sign in to comment.