PHP code example of mohammedmanssour / file-cast

1. Go to this page and download the library: Download mohammedmanssour/file-cast 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/ */

    

mohammedmanssour / file-cast example snippets


protected $casts = [
    'government_id' => FileCast::class, // uses table name as storage path, public visibility and the configured default disk
    'verification_video' => FileCast::class.':verification', // uses verification as storage path, public visisbility and the configured default disk
    'profile_picture' => FileCast::class.':pics,,s3', // uses pics as storage path, and s3 as storage disk
];

User::observe(UploadedFilesObserver::class);

$model->profile_picture->path(); // return the saved path in the db.
$model->profile_picture->fullPath(); // return the full path based on the provided disk
$model->profile_picture->size(); // return the file size
$model->profile_picture->url(); // return the file url based on the provided disk
$model->profile_picture->exists(); // return true of false
$model->profile_picture->delete(); // delete the file
bash
php artisan vendor:publish --tag="file-cast-config"