PHP code example of qisti / smart-ui-qisti

1. Go to this page and download the library: Download qisti/smart-ui-qisti library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

qisti / smart-ui-qisti example snippets


 <x-smartuiqisti::forms.upload-form 
    label="Supporting Document"
    name="documents"
    max-files="5"
    max-size="5"
    accept=".csv,.xls,.xlsx,.zip,.pdf,.png,.jpg,.jpeg"
    

public function store(Request $request)
{
    $data = $request->validate([
        'documents'   => ['  foreach ($data['documents'] as $file) {
        $file->store('documents', 'public');
    }
}

use Livewire\WithFileUploads;

class UploadDocuments extends Component
{
    use WithFileUploads;

    public $documents = [];

    public function save()
    {
        $this->validate([
            'documents'   => [''documents');
    }
}

Schema::create('letter_documents', function (Blueprint $table) {
    $table->id();
    $table->foreignId('letter_id')->constrained()->cascadeOnDelete();
    $table->string('path');       // where the file lives on the disk
    $table->string('filename');   // the name to show in the UI
    $table->unsignedInteger('sort_order')->default(0);
    $table->timestamps();
});

$existing = $letter->documents()->orderBy('sort_order')->get()->map(fn ($doc) => [
    'id'   => $doc->id,
    'name' => $doc->filename,
    'url'  => Storage::disk('public')->url($doc->path),
    'size' => Storage::disk('public')->size($doc->path),
]);

$data = $request->validate([
    // The user may keep a saved file and upload nothing new — so "'  => ['array'],
    'documents_existing.*' => ['string'],
    'documents_order'      => ['array'],
    'documents_order.*'    => ['string'],
]);

$kept = $data['documents_existing'] ?? [];

// Scoped to this letter, so a forged id cannot reach another record's rows.
$letter->documents()->whereNotIn('id', $kept)->get()->each(function ($doc) {
    Storage::disk('public')->delete($doc->path);
    $doc->delete();
});

$uploads = $request->file('documents', []);

foreach ($data['documents_order'] ?? [] as $position => $token) {
    [$kind, $ref] = array_pad(explode(':', $token, 2), 2, null);

    if ($kind === 'existing') {
        $letter->documents()->whereKey($ref)->update(['sort_order' => $position]);
    } elseif ($kind === 'new' && isset($uploads[$ref])) {
        $letter->documents()->create([
            'path'       => $uploads[$ref]->store('documents', 'public'),
            'filename'   => $uploads[$ref]->getClientOriginalName(),
            'sort_order' => $position,
        ]);
    }
}

public array $documents = [];
public array $keptDocuments = [];
public array $documentOrder = [];

public function mount(Letter $letter)
{
    // Seed both: if the user removes nothing, the browser never writes to these
    // properties, and empty ones would read as "delete everything".
    $this->keptDocuments = $letter->documents->pluck('id')->map(strval(...))->all();
    $this->documentOrder = array_map(fn ($id) => "existing:{$id}", $this->keptDocuments);
}

'documents' => ['array', 'max:'.max(0, 5 - count($request->input('documents_existing', [])))],

'smart-upload' => [
    'size' => 'sm',
],

return [
    'smart-upload' => [
        'accept'             => '.pdf,.png,.jpg,.jpeg',
        'max_files'          => 5,           // leave it out for unlimited
        'max_size'           => 10,          // MB
        'main_color'         => '',          // empty inherits --color-primary
        'size'               => 'sm',        // xs…9xl, a CSS length, or 'inherit'
        'icon'               => 'img/upload.svg',
        'hidden_icon'        => false,
        'tooltip_
bash
php artisan vendor:publish --tag=smartuiqisti-assets
bash
php artisan vendor:publish --tag=smartuiqisti-views
bash
php artisan vendor:publish --tag=smartuiqisti-config
blade
<x-smartuiqisti::forms.upload-form
    label="Supporting Document"
    wire:model="documents"
    max-files="5"
    max-size="5"
    
blade
<form action="{{ route('letters.update', $letter) }}" method="POST" enctype="multipart/form-data">
    @csrf
    @method('PUT')

    <x-smartuiqisti::forms.upload-form
        label="Supporting Document"
        name="documents"
        :existing-files="$existing"
        max-files="5"
        max-size="5"
        accept=".pdf,.png,.jpg" />

    <button type="submit">Save</button>
</form>
bash
php artisan vendor:publish --tag=smartuiqisti-config
blade
<x-smartuiqisti::forms.upload-form label="Passport" max-size="2" />