diff --git a/app/Http/Controllers/ShippingEntryController.php b/app/Http/Controllers/ShippingEntryController.php index 9b638dc..af5a6f3 100644 --- a/app/Http/Controllers/ShippingEntryController.php +++ b/app/Http/Controllers/ShippingEntryController.php @@ -4,26 +4,27 @@ namespace App\Http\Controllers; use App\Http\Requests\ShippingEntryRequest; use App\Models\ShippingEntry; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; class ShippingEntryController extends Controller { - public function index() {} + public function index(): void {} - public function create() {} + public function create(): void {} - public function store(ShippingEntryRequest $request) + public function store(ShippingEntryRequest $request): RedirectResponse { $entry = ShippingEntry::create($request->validated()); return redirect()->route('customers.show', [$entry->customer, 'tab' => 'shipping']); } - public function show($id) {} + public function show(int $id): void {} - public function edit($id) {} + public function edit(int $id): void {} - public function update(Request $request, $id) {} + public function update(Request $request, int $id): void {} - public function destroy($id) {} + public function destroy(int $id): void {} } diff --git a/app/Http/Requests/ContactRequest.php b/app/Http/Requests/ContactRequest.php index c27da6f..ba1eeca 100644 --- a/app/Http/Requests/ContactRequest.php +++ b/app/Http/Requests/ContactRequest.php @@ -6,6 +6,9 @@ use Illuminate\Foundation\Http\FormRequest; class ContactRequest extends FormRequest { + /** + * @return string[] + */ public function rules(): array { // todo: required first name if no last name and vice versa diff --git a/app/Http/Requests/CustomerRequest.php b/app/Http/Requests/CustomerRequest.php index fbf4a9f..929d720 100644 --- a/app/Http/Requests/CustomerRequest.php +++ b/app/Http/Requests/CustomerRequest.php @@ -6,18 +6,21 @@ use Illuminate\Foundation\Http\FormRequest; class CustomerRequest extends FormRequest { + /** + * @return array> + */ public function rules() { return [ - 'company_name' => 'required', - 'internal_name' => 'required', - 'shipping_address' => 'required', - 'billing_address' => 'required', - 'phone' => 'required', + 'company_name' => ['required'], + 'internal_name' => ['required'], + 'shipping_address' => ['required'], + 'billing_address' => ['required'], + 'phone' => ['required'], ]; } - public function authorize() + public function authorize(): bool { return true; } diff --git a/app/Http/Requests/OrderProductRequest.php b/app/Http/Requests/OrderProductRequest.php index 6bd0f32..b3f1877 100644 --- a/app/Http/Requests/OrderProductRequest.php +++ b/app/Http/Requests/OrderProductRequest.php @@ -6,6 +6,9 @@ use Illuminate\Foundation\Http\FormRequest; class OrderProductRequest extends FormRequest { + /** + * @return array> + */ public function rules(): array { return [ diff --git a/app/Http/Requests/OrderRequest.php b/app/Http/Requests/OrderRequest.php index 01ce8d3..8236ac5 100644 --- a/app/Http/Requests/OrderRequest.php +++ b/app/Http/Requests/OrderRequest.php @@ -6,6 +6,9 @@ use Illuminate\Foundation\Http\FormRequest; class OrderRequest extends FormRequest { + /** + * @return array> + */ public function rules(): array { return [ diff --git a/app/Http/Requests/PackingSlipRequest.php b/app/Http/Requests/PackingSlipRequest.php index b2a1669..58d4f9c 100644 --- a/app/Http/Requests/PackingSlipRequest.php +++ b/app/Http/Requests/PackingSlipRequest.php @@ -6,15 +6,18 @@ use Illuminate\Foundation\Http\FormRequest; class PackingSlipRequest extends FormRequest { + /** + * @return string> + */ public function rules(): array { return [ - 'date_received' => 'required|date', - 'customer_id' => 'required|exists:customers,id', - 'order_id' => 'string|nullable', - 'amount' => 'required|string', - 'contents' => 'required|string', - 'from_customer' => 'required|bool', + 'date_received' => ['required|date'], + 'customer_id' => ['required|exists:customers,id'], + 'order_id' => ['string|nullable'], + 'amount' => ['required|string'], + 'contents' => ['required|string'], + 'from_customer' => ['required|bool'], ]; } diff --git a/app/Http/Requests/ProductServiceRequest.php b/app/Http/Requests/ProductServiceRequest.php index 6b0f49f..f07130f 100644 --- a/app/Http/Requests/ProductServiceRequest.php +++ b/app/Http/Requests/ProductServiceRequest.php @@ -6,6 +6,9 @@ use Illuminate\Foundation\Http\FormRequest; class ProductServiceRequest extends FormRequest { + /** + * @return array> + */ public function rules(): array { return [ diff --git a/app/Http/Requests/ProductSizeRequest.php b/app/Http/Requests/ProductSizeRequest.php index 6c5894a..8187fc9 100644 --- a/app/Http/Requests/ProductSizeRequest.php +++ b/app/Http/Requests/ProductSizeRequest.php @@ -6,6 +6,9 @@ use Illuminate\Foundation\Http\FormRequest; class ProductSizeRequest extends FormRequest { + /** + * @return array> + */ public function rules(): array { return [ diff --git a/app/Http/Requests/ServiceFileRequest.php b/app/Http/Requests/ServiceFileRequest.php index 3e73e6a..81b1f0c 100644 --- a/app/Http/Requests/ServiceFileRequest.php +++ b/app/Http/Requests/ServiceFileRequest.php @@ -6,6 +6,9 @@ use Illuminate\Foundation\Http\FormRequest; class ServiceFileRequest extends FormRequest { + /** + * @return array> + */ public function rules(): array { return [ diff --git a/app/Http/Requests/ShippingEntryRequest.php b/app/Http/Requests/ShippingEntryRequest.php index d665dba..5bfd16c 100644 --- a/app/Http/Requests/ShippingEntryRequest.php +++ b/app/Http/Requests/ShippingEntryRequest.php @@ -6,6 +6,9 @@ use Illuminate\Foundation\Http\FormRequest; class ShippingEntryRequest extends FormRequest { + /** + * @return array> + */ public function rules(): array { return [ diff --git a/app/Livewire/OrderProductsCreate.php b/app/Livewire/OrderProductsCreate.php index 89867a6..2f9db1d 100644 --- a/app/Livewire/OrderProductsCreate.php +++ b/app/Livewire/OrderProductsCreate.php @@ -3,7 +3,10 @@ namespace App\Livewire; use Exception; +use Illuminate\Contracts\View\Factory; +use Illuminate\Foundation\Application; use Illuminate\Support\Collection; +use Illuminate\View\View; use Livewire\Component; class OrderProductsCreate extends Component @@ -12,21 +15,30 @@ class OrderProductsCreate extends Component public Collection $serviceInputs; + /** + * @var array + */ public array $sizes = []; public array $totals = []; public array $units = []; + /** + * @var array + */ public array $prices = []; + /** + * @var array + */ public array $priceTotals = []; public int $totalQuantity = 0; public string $totalPrice = '$0.00'; - public function updated() + public function updated(): void { try { foreach ($this->sizes as $index => $size) { @@ -48,7 +60,7 @@ class OrderProductsCreate extends Component } - public function addProductInput() + public function addProductInput(): void { $index = $this->productInputs->count(); $this->productInputs->push([ @@ -69,28 +81,28 @@ class OrderProductsCreate extends Component ]); } - public function determineAddProductRow($index) + public function determineAddProductRow(int $index): void { if ($index == $this->productInputs->count() - 1) { $this->addProductInput(); } } - public function determineAddServiceProductRow($index) + public function determineAddServiceProductRow(int $index): void { if ($index == $this->serviceInputs->count() - 1) { $this->addServiceInput(); } } - public function removeProductInput($key) + public function removeProductInput(int $key): void { if ($this->productInputs->count() > 1) { $this->productInputs->pull($key); } } - public function addServiceInput() + public function addServiceInput(): void { $this->serviceInputs->push([ $this->serviceInputs->count() => [ @@ -108,14 +120,14 @@ class OrderProductsCreate extends Component ]); } - public function removeServiceInput($key) + public function removeServiceInput(int $key): void { if ($this->serviceInputs->count() > 1) { $this->serviceInputs->pull($key); } } - public function mount() + public function mount(): void { $this->fill([ 'productInputs' => collect([ @@ -151,7 +163,7 @@ class OrderProductsCreate extends Component ]); } - public function render() + public function render(): \Illuminate\Contracts\View\View|Factory|Application|View { return view('livewire.order-products-create'); } diff --git a/app/Livewire/OrdersTable.php b/app/Livewire/OrdersTable.php index 897ca36..e529cdd 100644 --- a/app/Livewire/OrdersTable.php +++ b/app/Livewire/OrdersTable.php @@ -3,7 +3,10 @@ namespace App\Livewire; use App\Models\Order; +use Illuminate\Contracts\View\Factory; +use Illuminate\Foundation\Application; use Illuminate\Support\Carbon; +use Illuminate\View\View; use Livewire\Component; use Livewire\WithPagination; @@ -11,7 +14,7 @@ class OrdersTable extends Component { use WithPagination; - protected $paginationTheme = 'bootstrap'; + protected string $paginationTheme = 'bootstrap'; public bool $showCustomerColumn; @@ -25,7 +28,7 @@ class OrdersTable extends Component public Carbon $today; - public function mount(bool $showCustomerColumn, string $orderType, string $title, ?string $customer_id = null) + public function mount(bool $showCustomerColumn, string $orderType, string $title, ?string $customer_id = null): void { $this->today = Carbon::today(); $this->showCustomerColumn = $showCustomerColumn; @@ -34,7 +37,7 @@ class OrdersTable extends Component $this->customer_id = $customer_id ?? ''; } - public function render() + public function render(): \Illuminate\Contracts\View\View|Factory|Application|View { return view('livewire.orders-table', [ 'orders' => Order::with('customer') diff --git a/app/Models/Contact.php b/app/Models/Contact.php index cc17114..0918e9d 100644 --- a/app/Models/Contact.php +++ b/app/Models/Contact.php @@ -2,6 +2,7 @@ namespace App\Models; +use Database\Factories\ContactFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -9,6 +10,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; class Contact extends Model { + /** @use HasFactory */ use HasFactory, SoftDeletes; protected $fillable = [ @@ -25,6 +27,9 @@ class Contact extends Model return $this->first_name.' '.$this->last_name; } + /** + * @return BelongsTo + */ public function customer(): BelongsTo { return $this->belongsTo(Customer::class); diff --git a/app/Models/Customer.php b/app/Models/Customer.php index 8b256eb..771f1b5 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -2,6 +2,7 @@ namespace App\Models; +use Database\Factories\CustomerFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; @@ -9,6 +10,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; class Customer extends Model { + /** @use HasFactory */ use HasFactory, SoftDeletes; protected $fillable = [ @@ -19,21 +21,33 @@ class Customer extends Model 'phone', ]; + /** + * @return HasMany + */ public function contacts(): HasMany { return $this->hasMany(Contact::class); } + /** + * @return HasMany + */ public function packingSlips(): HasMany { return $this->hasMany(PackingSlip::class); } + /** + * @return HasMany + */ public function shippingEntries(): HasMany { return $this->hasMany(ShippingEntry::class); } + /** + * @return HasMany + */ public function orders(): HasMany { return $this->hasMany(Order::class); diff --git a/app/Models/Order.php b/app/Models/Order.php index 6de9166..a7f49b3 100644 --- a/app/Models/Order.php +++ b/app/Models/Order.php @@ -3,7 +3,9 @@ namespace App\Models; use App\Enums\OrderStatus; +use Database\Factories\OrderFactory; use DateTimeInterface; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -12,6 +14,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; class Order extends Model { + /** @use HasFactory */ use HasFactory, SoftDeletes; protected $fillable = [ @@ -36,7 +39,7 @@ class Order extends Model 'active', ]; - public static function boot() + public static function boot(): void { parent::boot(); @@ -46,9 +49,9 @@ class Order extends Model }); } - public function generateInternalPo($id): string + public function generateInternalPo(int $id): string { - $po = str_pad($id, 4, '0', STR_PAD_LEFT); + $po = str_pad(strval($id), 4, '0', STR_PAD_LEFT); $year = date('y'); return 'TN'.$year.'-'.$po; @@ -64,38 +67,63 @@ class Order extends Model return false; } - public function scopeActive($query) + /** + * @param Builder $query + * @return Builder + */ + public function scopeActive(Builder $query): Builder { return $query->where('status', 'approved') ->orWhere('status', 'production'); } - public function scopeFinished($query) + /** + * @param Builder $query + * @return Builder + */ + public function scopeFinished(Builder $query): Builder { return $query->where('status', 'shipped') ->orWhere('status', 'completed'); } - public function scopeInvoiced($query) + /** + * @param Builder $query + * @return Builder + */ + public function scopeInvoiced(Builder $query): Builder { return $query->where('status', 'invoiced'); } - public function scopeRush($query) + /** + * @param Builder $query + * @return Builder + */ + public function scopeRush(Builder $query): Builder { return $query->where('rush', true); } + /** + * @return BelongsTo + */ public function customer(): BelongsTo { return $this->belongsTo(Customer::class); } + /** + * @return HasMany + */ public function orderProducts(): HasMany { return $this->hasMany(OrderProduct::class); } + /** + * @return HasMany + */ public function productServices(): HasMany { return $this->hasMany(ProductService::class); diff --git a/app/Models/OrderProduct.php b/app/Models/OrderProduct.php index 76e7b12..c5be45c 100644 --- a/app/Models/OrderProduct.php +++ b/app/Models/OrderProduct.php @@ -2,6 +2,7 @@ namespace App\Models; +use Database\Factories\OrderProductFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -11,6 +12,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; class OrderProduct extends Model { + /** @use HasFactory */ use HasFactory, SoftDeletes; protected $fillable = [ @@ -20,16 +22,25 @@ class OrderProduct extends Model 'color', ]; + /** + * @return BelongsTo + */ public function order(): BelongsTo { return $this->belongsTo(Order::class); } + /** + * @return HasOne + */ public function serviceFile(): HasOne { return $this->hasOne(ServiceFile::class); } + /** + * @return HasMany + */ public function productSize(): HasMany { return $this->hasMany(ProductSize::class); diff --git a/app/Models/PackingSlip.php b/app/Models/PackingSlip.php index 57c63d8..9d6f9e4 100644 --- a/app/Models/PackingSlip.php +++ b/app/Models/PackingSlip.php @@ -2,6 +2,7 @@ namespace App\Models; +use Database\Factories\PackingSlipFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -9,6 +10,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; class PackingSlip extends Model { + /** @use HasFactory */ use HasFactory, SoftDeletes; protected $fillable = [ @@ -19,6 +21,9 @@ class PackingSlip extends Model 'contents', ]; + /** + * @return BelongsTo + */ public function customer(): BelongsTo { return $this->belongsTo(Customer::class); diff --git a/app/Models/ProductService.php b/app/Models/ProductService.php index f4929b8..eda51e4 100644 --- a/app/Models/ProductService.php +++ b/app/Models/ProductService.php @@ -2,6 +2,7 @@ namespace App\Models; +use Database\Factories\ProductServiceFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -10,6 +11,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; class ProductService extends Model { + /** @use HasFactory */ use HasFactory, SoftDeletes; protected $fillable = [ @@ -21,11 +23,17 @@ class ProductService extends Model 'amount_price', ]; + /** + * @return BelongsTo + */ public function order(): BelongsTo { return $this->belongsTo(Order::class); } + /** + * @return HasOne + */ public function serviceFile(): HasOne { return $this->hasOne(ServiceFile::class); diff --git a/app/Models/ProductSize.php b/app/Models/ProductSize.php index 573dc09..215fe53 100644 --- a/app/Models/ProductSize.php +++ b/app/Models/ProductSize.php @@ -2,6 +2,7 @@ namespace App\Models; +use Database\Factories\ProductSizeFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -9,6 +10,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; class ProductSize extends Model { + /** @use HasFactory */ use HasFactory, SoftDeletes; protected $fillable = [ @@ -17,6 +19,9 @@ class ProductSize extends Model 'amount', ]; + /** + * @return BelongsTo + */ public function orderProduct(): BelongsTo { return $this->belongsTo(OrderProduct::class); diff --git a/app/Models/ServiceFile.php b/app/Models/ServiceFile.php index 0f08cd1..597f361 100644 --- a/app/Models/ServiceFile.php +++ b/app/Models/ServiceFile.php @@ -2,6 +2,7 @@ namespace App\Models; +use Database\Factories\ServiceFileFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -9,6 +10,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; class ServiceFile extends Model { + /** @use HasFactory */ use HasFactory, SoftDeletes; protected $fillable = [ @@ -21,6 +23,9 @@ class ServiceFile extends Model 'setup_number', ]; + /** + * @return BelongsTo + */ public function productService(): BelongsTo { return $this->belongsTo(ProductService::class); diff --git a/app/Models/ShippingEntry.php b/app/Models/ShippingEntry.php index b2b9a15..a4386a7 100644 --- a/app/Models/ShippingEntry.php +++ b/app/Models/ShippingEntry.php @@ -3,6 +3,7 @@ namespace App\Models; use App\Enums\ShippingType; +use Database\Factories\ShippingEntryFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -10,6 +11,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; class ShippingEntry extends Model { + /** @use HasFactory */ use HasFactory, SoftDeletes; protected $casts = [ @@ -29,6 +31,9 @@ class ShippingEntry extends Model 'notes', ]; + /** + * @return BelongsTo + */ public function customer(): BelongsTo { return $this->belongsTo(Customer::class); diff --git a/app/Models/User.php b/app/Models/User.php index 7843cf3..e08fea3 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -3,12 +3,14 @@ namespace App\Models; // use Illuminate\Contracts\Auth\MustVerifyEmail; +use Database\Factories\UserFactory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; class User extends Authenticatable { + /** @use HasFactory */ use HasFactory, Notifiable; /**