PHP code example of ahmedkandel / nova-s3-multipart-upload

1. Go to this page and download the library: Download ahmedkandel/nova-s3-multipart-upload 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/ */

    

ahmedkandel / nova-s3-multipart-upload example snippets


use Ahmedkandel\NovaS3MultipartUpload\NovaS3MultipartUpload;

class Post extends Resource
{
    public function fields(Request $request)
    {
        return [
            // ...
            NovaS3MultipartUpload::make('Video'),
        ];
    }
}

class Post extends Model
{
    protected $fillable = ['video'];
}

class Post extends Model
{
    protected $casts = [
        'videos' => 'array',
    ];
}

        ->storeMeta(
            [
                'file_author' => [
                    'name' => 'Author',
                    'placeholder' => 'your name please!',
                    'default' => 'No Author',
                ],
                'file_description' => [
                    'name' => 'Description',
                ],
                'file_uploaded_at' => [
                    'name' => 'Uploaded At',
                    'default' => now(),
                    'ui' => false,
                ],
            ]
        )
		

        ->restrictions(
            [
                'maxFileSize' => 1024 * 1024 * 1024,
                'minFileSize' => 50 * 1024,
                'maxTotalFileSize' => 10 * 1024 * 1024 * 1024,
                'maxNumberOfFiles' => 10,
                'minNumberOfFiles' => 2,
                'allowedFileTypes' => [
                    'image/*',
                    'video/*',
                    '.pdf',
                ],
            ]
        )
		

        ->translate(
            [
                'dropPasteImportBoth' => 'Trascina i file qui, sfoglia %{browseFiles} o %{browseFolders}',
                'browseFiles' => 'i file',
                'browseFolders' => 'le cartelle',
                'myDevice' => 'Dispositivo',
                'screencast' => 'Schermo',
            ]
        )
		

class User extends Model
{
    protected $fillable = ['files'];
    
    protected $casts = [
        'files' => 'array',
    ];
}

use Ahmedkandel\NovaS3MultipartUpload\NovaS3MultipartUpload;

class User extends Resource
{
    public function fields(Request $request)
    {
        return [
            // ...
            NovaS3MultipartUpload::make('Files')
                ->path($request->user()->id.'-uploads')
                ->storeAsMultipleArray('file_path')
                ->storeName('file_name')
                ->storeSize('file_size')
                ->storeMeta(
                    [
                        'file_author' => [
                            'name' => 'Author',
                            'placeholder' => 'your name please!',
                            'default' => 'No Author',
                        ],
                        'file_description' => [
                            'name' => 'Description',
                        ],
                    ]
                ),
        ];
    }
}

->canUpload(function () {
    return empty($this->model()->video);
})

->canDelete(function () {
    return request()->user()->id === $this->model()->user_id;
})

	[
		'autoOpen' => true,
	]