Skip to content

Commit

Permalink
chore: fix laravel pint and phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Dartui committed Jun 16, 2024
1 parent 555f879 commit 29a9696
Show file tree
Hide file tree
Showing 27 changed files with 330 additions and 472 deletions.
18 changes: 1 addition & 17 deletions src/Model/Builder/OrderBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ class OrderBuilder extends PostBuilder
{
/**
* Scope a query to only cancelled orders.
*
* @return \Corcel\Model\Builder\PostBuilder
*/
public function cancelled(): PostBuilder
{
Expand All @@ -20,8 +18,6 @@ public function cancelled(): PostBuilder

/**
* Scope a query to only completed orders.
*
* @return \Corcel\Model\Builder\PostBuilder
*/
public function completed(): PostBuilder
{
Expand All @@ -30,8 +26,6 @@ public function completed(): PostBuilder

/**
* Scope a query to only failed orders.
*
* @return \Corcel\Model\Builder\PostBuilder
*/
public function failed(): PostBuilder
{
Expand All @@ -40,8 +34,6 @@ public function failed(): PostBuilder

/**
* Scope a query to only on hold orders.
*
* @return \Corcel\Model\Builder\PostBuilder
*/
public function onHold(): PostBuilder
{
Expand All @@ -50,8 +42,6 @@ public function onHold(): PostBuilder

/**
* Scope a query to only pending orders.
*
* @return \Corcel\Model\Builder\PostBuilder
*/
public function pending(): PostBuilder
{
Expand All @@ -60,8 +50,6 @@ public function pending(): PostBuilder

/**
* Scope a query to only processing orders.
*
* @return \Corcel\Model\Builder\PostBuilder
*/
public function processing(): PostBuilder
{
Expand All @@ -70,8 +58,6 @@ public function processing(): PostBuilder

/**
* Scope a query to only refunded orders.
*
* @return \Corcel\Model\Builder\PostBuilder
*/
public function refunded(): PostBuilder
{
Expand All @@ -80,12 +66,10 @@ public function refunded(): PostBuilder

/**
* Scope a query to orders with given status.
*
* @return \Corcel\Model\Builder\PostBuilder
*/
public function status($status): PostBuilder
{
$status = 'wc-' === substr($status, 0, 3) ? substr($status, 3) : $status;
$status = substr($status, 0, 3) === 'wc-' ? substr($status, 3) : $status;

$builtin = [
'cancelled',
Expand Down
14 changes: 6 additions & 8 deletions src/Model/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
use Illuminate\Database\Eloquent\Relations\HasMany;

/**
* @property int $order_count
* @property Collection $orders
* @property int $order_count
* @property Collection $orders
*/
class Customer extends User
{
use HasFactory;
use AddressesTrait;
use HasFactory;

/**
* @use HasRelationsThroughMeta<\Illuminate\Database\Eloquent\Model>
*/
use HasRelationsThroughMeta;

/**
* @inheritDoc
* {@inheritDoc}
*
* @var array<string>
* @var array<string>
*/
protected $appends = [
'order_count',
Expand All @@ -46,8 +46,6 @@ protected static function newFactory()

/**
* Get order count attribute.
*
* @return int
*/
protected function getOrderCountAttribute(): int
{
Expand All @@ -59,7 +57,7 @@ protected function getOrderCountAttribute(): int
/**
* Get the related orders.
*
* @return HasMany<\Illuminate\Database\Eloquent\Model>
* @return HasMany<\Illuminate\Database\Eloquent\Model>
*/
public function orders(): HasMany
{
Expand Down
82 changes: 35 additions & 47 deletions src/Model/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,47 @@
use Illuminate\Database\Eloquent\Relations\HasMany;

/**
* @property int $id
* @property string $name
* @property string $type
* @property int $order_item_id
* @property string $order_item_name
* @property string $order_item_type
* @property int $order_id
* @property string|null $product_id
* @property string|null $variation_id
* @property string|null $quantity
* @property string|null $tax_class
* @property string|null $line_subtotal
* @property string|null $line_subtotal_tax
* @property string|null $line_total
* @property string|null $line_tax
* @property \Corcel\WooCommerce\Model\Order $order
* @property \Corcel\WooCommerce\Model\Product $product
* @property int $id
* @property string $name
* @property string $type
* @property int $order_item_id
* @property string $order_item_name
* @property string $order_item_type
* @property int $order_id
* @property string|null $product_id
* @property string|null $variation_id
* @property string|null $quantity
* @property string|null $tax_class
* @property string|null $line_subtotal
* @property string|null $line_subtotal_tax
* @property string|null $line_total
* @property string|null $line_tax
* @property \Corcel\WooCommerce\Model\Order $order
* @property \Corcel\WooCommerce\Model\Product $product
*/
class Item extends Model
{
use HasFactory;
use Aliases;
use HasFactory;
use MetaFields;

/**
* The model aliases.
*
* @var array<string, string>|array<string, array<string, string>>
* @var array<string, string>|array<string, array<string, string>>
*/
protected static $aliases = [
'id' => 'order_item_id',
'name' => 'order_item_name',
'type' => 'order_item_type',
'product_id' => ['meta' => '_product_id'],
'id' => 'order_item_id',
'name' => 'order_item_name',
'type' => 'order_item_type',
'product_id' => ['meta' => '_product_id'],
'variation_id' => ['meta' => '_variation_id'],
];

/**
* @inheritDoc
* {@inheritDoc}
*
* @var array<int, string>
* @var array<int, string>
*/
protected $appends = [
'quantity',
Expand All @@ -66,23 +66,23 @@ class Item extends Model
];

/**
* @inheritDoc
* {@inheritDoc}
*
* @var string
* @var string
*/
protected $table = 'woocommerce_order_items';

/**
* @inheritDoc
* {@inheritDoc}
*
* @var string
* @var string
*/
protected $primaryKey = 'order_item_id';

/**
* @inheritDoc
* {@inheritDoc}
*
* @var bool
* @var bool
*/
public $timestamps = false;

Expand All @@ -98,8 +98,6 @@ protected static function newFactory()

/**
* Get the line subtotal attribute.
*
* @return string|null
*/
protected function getLineSubtotalAttribute(): ?string
{
Expand All @@ -110,8 +108,6 @@ protected function getLineSubtotalAttribute(): ?string

/**
* Get the line subtotal tax attribute.
*
* @return string|null
*/
protected function getLineSubtotalTaxAttribute(): ?string
{
Expand All @@ -122,8 +118,6 @@ protected function getLineSubtotalTaxAttribute(): ?string

/**
* Get the line tax attribute.
*
* @return string|null
*/
protected function getLineTaxAttribute(): ?string
{
Expand All @@ -134,8 +128,6 @@ protected function getLineTaxAttribute(): ?string

/**
* Get the line total attribute.
*
* @return string|null
*/
protected function getLineTotalAttribute(): ?string
{
Expand All @@ -146,8 +138,6 @@ protected function getLineTotalAttribute(): ?string

/**
* Get the quantity attribute.
*
* @return string|null
*/
protected function getQuantityAttribute(): ?string
{
Expand All @@ -158,8 +148,6 @@ protected function getQuantityAttribute(): ?string

/**
* Get the tax class attribute.
*
* @return string|null
*/
protected function getTaxClassAttribute(): ?string
{
Expand All @@ -169,9 +157,9 @@ protected function getTaxClassAttribute(): ?string
}

/**
* @inheritDoc
* {@inheritDoc}
*
* @return HasMany<ItemMeta>
* @return HasMany<ItemMeta>
*/
public function meta(): HasMany
{
Expand All @@ -181,7 +169,7 @@ public function meta(): HasMany
/**
* Get the related order.
*
* @return BelongsTo<Order, Item>
* @return BelongsTo<Order, Item>
*/
public function order(): BelongsTo
{
Expand All @@ -191,7 +179,7 @@ public function order(): BelongsTo
/**
* Get the related product.
*
* @return BelongsTo<Product, Item>
* @return BelongsTo<Product, Item>
*/
public function product(): BelongsTo
{
Expand Down
8 changes: 4 additions & 4 deletions src/Model/Meta/ItemMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
class ItemMeta extends PostMeta
{
/**
* @inheritDoc
* {@inheritDoc}
*
* @var string
* @var string
*/
protected $table = 'woocommerce_order_itemmeta';

/**
* @inheritDoc
* {@inheritDoc}
*
* @var string[]
* @var string[]
*/
protected $fillable = [
'order_item_id',
Expand Down
Loading

0 comments on commit 29a9696

Please sign in to comment.