Skip to content

Commit

Permalink
chore: add property annotations to models
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Poyigi <[email protected]>
  • Loading branch information
sampoyigi committed Jan 3, 2025
1 parent 4073de4 commit ed80200
Show file tree
Hide file tree
Showing 22 changed files with 279 additions and 317 deletions.
314 changes: 2 additions & 312 deletions phpstan-baseline.neon

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Classes/CartManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ public function validateMenuItemOption(MenuItemOption $menuOption, $selectedValu
}

if ($menuOption->display_type == 'quantity') {
$countSelected = array_reduce($selectedValues, function($qty, $selectedValue) {
$countSelected = (int)array_reduce($selectedValues, function($qty, $selectedValue) {
return $qty + $selectedValue['qty'];
});
} else {
Expand Down
10 changes: 10 additions & 0 deletions src/Models/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@

use Igniter\Flame\Database\Model;

/**
* Cart Model Class
*
* @property string $identifier
* @property string $instance
* @property string $data
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @mixin \Igniter\Flame\Database\Model
*/
class Cart extends Model
{
protected $table = 'igniter_cart_cart';
Expand Down
2 changes: 1 addition & 1 deletion src/Models/CartSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Igniter\Flame\Database\Model;

/**
* @method static instance()
* @method static CartSettings instance()
*/
class CartSettings extends Model
{
Expand Down
19 changes: 19 additions & 0 deletions src/Models/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@

/**
* Category Model Class
*
* @property int $category_id
* @property string $name
* @property string|null $description
* @property int|null $parent_id
* @property int $priority
* @property bool $status
* @property int|null $nest_left
* @property int|null $nest_right
* @property string|null $permalink_slug
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Kalnoy\Nestedset\Collection<int, Category> $children
* @property-read int|null $children_count
* @property-read mixed $count_menus
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Igniter\Flame\Database\Attach\Media> $media
* @property-read int|null $media_count
* @property-read Category|null $parent
* @mixin \Igniter\Flame\Database\Model
*/
class Category extends Model
{
Expand Down
12 changes: 12 additions & 0 deletions src/Models/Ingredient.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@

/**
* Ingredients Model Class
*
* @property int $ingredient_id
* @property string $name
* @property string $description
* @property bool $status
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property bool $is_allergen
* @property-read mixed $count_menus
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Igniter\Flame\Database\Attach\Media> $media
* @property-read int|null $media_count
* @mixin \Igniter\Flame\Database\Model
*/
class Ingredient extends Model
{
Expand Down
11 changes: 10 additions & 1 deletion src/Models/Mealtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@

/**
* Mealtime Model Class
*
* @property int $mealtime_id
* @property string $mealtime_name
* @property mixed $start_time
* @property mixed $end_time
* @property bool $mealtime_status
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @mixin \Igniter\Flame\Database\Model
*/
class Mealtime extends Model
{
Expand Down Expand Up @@ -61,7 +70,7 @@ public function isAvailable($datetime = null)

return $datetime->between(
$datetime->setTimeFromTimeString($this->start_time),
$datetime->setTimeFromTimeString($this->end_time)
$datetime->setTimeFromTimeString($this->end_time),
);
}

Expand Down
16 changes: 16 additions & 0 deletions src/Models/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@

/**
* Menu Model Class
*
* @property int $menu_id
* @property string $menu_name
* @property string $menu_description
* @property float $menu_price
* @property int $minimum_qty
* @property boolean $menu_status
* @property int $menu_priority
* @property array|null $order_restriction
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read mixed $menu_price_from
* @property-read mixed $stock_qty
* @property-read \Illuminate\Database\Eloquent\Collection<int, \Igniter\Flame\Database\Attach\Media> $media
* @property-read int|null $media_count
* @mixin \Igniter\Flame\Database\Model
*/
class Menu extends Model implements Buyable
{
Expand Down
4 changes: 4 additions & 0 deletions src/Models/MenuCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

/**
* MenuCategory Model Class
*
* @property int $menu_id
* @property int $category_id
* @mixin \Igniter\Flame\Database\Model
*/
class MenuCategory extends Model
{
Expand Down
16 changes: 16 additions & 0 deletions src/Models/MenuExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@

use IgniterLabs\ImportExport\Models\ExportModel;

/**
* MenuExport Model Class
*
* @property int $menu_id
* @property string $menu_name
* @property string $menu_description
* @property string $menu_price
* @property int $minimum_qty
* @property boolean $menu_status
* @property int $menu_priority
* @property string|null $order_restriction
* @property string|null $created_at
* @property string|null $updated_at
* @property-read mixed $categories
* @mixin \Igniter\Flame\Database\Model
*/
class MenuExport extends ExportModel
{
protected $table = 'menus';
Expand Down
15 changes: 15 additions & 0 deletions src/Models/MenuImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@
use Exception;
use IgniterLabs\ImportExport\Models\ImportModel;

/**
* MenuImport Model Class
*
* @property int $menu_id
* @property string $menu_name
* @property string $menu_description
* @property string $menu_price
* @property int $minimum_qty
* @property boolean $menu_status
* @property int $menu_priority
* @property string|null $order_restriction
* @property string|null $created_at
* @property string|null $updated_at
* @mixin \Igniter\Flame\Database\Model
*/
class MenuImport extends ImportModel
{
protected $table = 'menus';
Expand Down
17 changes: 17 additions & 0 deletions src/Models/MenuItemOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@
use Igniter\Flame\Database\Traits\Purgeable;
use Igniter\Flame\Database\Traits\Validation;

/**
* MenuItemOption Model Class
*
* @property int $menu_option_id
* @property int $option_id
* @property int $menu_id
* @property bool $is_required
* @property int $priority
* @property int $min_selected
* @property int $max_selected
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read mixed $display_type
* @property-read mixed $option_name
* @property-read mixed $option_values
* @mixin \Igniter\Flame\Database\Model
*/
class MenuItemOption extends Model
{
use HasFactory;
Expand Down
12 changes: 12 additions & 0 deletions src/Models/MenuItemOptionValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@

/**
* MenuItemOptionValue Model Class
*
* @property int $menu_option_value_id
* @property int $menu_option_id
* @property int $option_value_id
* @property float|null $override_price
* @property int $priority
* @property bool|null $is_default
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read mixed $name
* @property-read mixed $price
* @mixin \Igniter\Flame\Database\Model
*/
class MenuItemOptionValue extends Model
{
Expand Down
8 changes: 8 additions & 0 deletions src/Models/MenuOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@

/**
* MenuOption Model Class
*
* @property int $option_id
* @property string $option_name
* @property string $display_type
* @property int $priority
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @mixin \Igniter\Flame\Database\Model
*/
class MenuOption extends Model
{
Expand Down
8 changes: 8 additions & 0 deletions src/Models/MenuOptionValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@

/**
* MenuOptionValue Model Class
*
* @property int $option_value_id
* @property int $option_id
* @property string $name
* @property float|null $price
* @property int $priority
* @property-read mixed $stock_qty
* @mixin \Igniter\Flame\Database\Model
*/
class MenuOptionValue extends Model
{
Expand Down
16 changes: 16 additions & 0 deletions src/Models/MenuSpecial.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@

/**
* MenuSpecial Model Class
*
* @property int $special_id
* @property int $menu_id
* @property \Illuminate\Support\Carbon|null $start_date
* @property \Illuminate\Support\Carbon|null $end_date
* @property float|null $special_price
* @property bool $special_status
* @property string $type
* @property string $validity
* @property array|null $recurring_every
* @property mixed|null $recurring_from
* @property mixed|null $recurring_to
* @property string|null $created_at
* @property string|null $updated_at
* @property-read mixed $pretty_end_date
* @mixin \Igniter\Flame\Database\Model
*/
class MenuSpecial extends Model
{
Expand Down
48 changes: 46 additions & 2 deletions src/Models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,49 @@

/**
* Order Model Class
*
* @property int $order_id
* @property int|null $customer_id
* @property string $first_name
* @property string $last_name
* @property string $email
* @property string $telephone
* @property int $location_id
* @property int|null $address_id
* @property mixed $cart
* @property int $total_items
* @property string|null $comment
* @property string $payment
* @property string $order_type
* @property \Illuminate\Support\Carbon $created_at
* @property \Illuminate\Support\Carbon $updated_at
* @property mixed $order_time
* @property \Illuminate\Support\Carbon $order_date
* @property float|null $order_total
* @property int $status_id
* @property string $ip_address
* @property string $user_agent
* @property int|null $assignee_id
* @property int|null $assignee_group_id
* @property string|null $invoice_prefix
* @property \Illuminate\Support\Carbon|null $invoice_date
* @property string|null $hash
* @property bool|null $processed
* @property \Illuminate\Support\Carbon|null $status_updated_at
* @property \Illuminate\Support\Carbon|null $assignee_updated_at
* @property bool $order_time_is_asap
* @property string|null $delivery_comment
* @property-read mixed $customer_name
* @property-read mixed $formatted_address
* @property-read mixed $invoice_no
* @property-read mixed $invoice_number
* @property-read mixed $order_datetime
* @property-read mixed $order_type_name
* @property-read string|null $status_color
* @property-read string|null $status_name
* @method static \Igniter\Flame\Database\Builder<static>|Order whereHasAutoAssignGroup()
* @method static \Igniter\Flame\Database\Builder<static>|Order whereHasStatusInHistory(string|int $statusId)
* @mixin \Igniter\Flame\Database\Model
*/
class Order extends Model
{
Expand Down Expand Up @@ -379,9 +422,10 @@ public function mailGetData()
$data['location_address'] = format_address($model->location->getAddress());
}

/** @var StatusHistory $statusHistory */
$statusHistory = StatusHistory::applyRelated($model)->whereStatusIsLatest($model->status_id)->first();
$data['status_name'] = $statusHistory ? optional($statusHistory->status)->status_name : null;
$data['status_comment'] = $statusHistory ? $statusHistory->comment : null;
$data['status_name'] = $statusHistory?->status?->status_name;
$data['status_comment'] = $statusHistory?->comment;

$controller = MainController::getController();
$data['order_view_url'] = $controller->pageUrl('account/order', [
Expand Down
14 changes: 14 additions & 0 deletions src/Models/OrderMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@

use Igniter\Flame\Database\Casts\Serialize;

/**
* OrderMenu Model
*
* @property int $order_menu_id
* @property int $order_id
* @property int $menu_id
* @property string $name
* @property int $quantity
* @property float|null $price
* @property float|null $subtotal
* @property mixed|null $option_values
* @property string|null $comment
* @mixin \Igniter\Flame\Database\Model
*/
class OrderMenu extends \Igniter\Flame\Database\Model
{
protected $table = 'order_menus';
Expand Down
14 changes: 14 additions & 0 deletions src/Models/OrderMenuOptionValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

namespace Igniter\Cart\Models;

/**
* OrderMenuOptionValue Model
*
* @property int $order_option_id
* @property int $order_id
* @property string $order_option_name
* @property float|null $order_option_price
* @property int $order_menu_id
* @property int $menu_option_id
* @property int $menu_option_value_id
* @property int|null $quantity
* @property-read mixed $order_option_category
* @mixin \Igniter\Flame\Database\Model
*/
class OrderMenuOptionValue extends \Igniter\Flame\Database\Model
{
protected $table = 'order_menu_options';
Expand Down
Loading

0 comments on commit ed80200

Please sign in to comment.