PHP code example of agenticmorf / fluxui-avatar

1. Go to this page and download the library: Download agenticmorf/fluxui-avatar 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/ */

    

agenticmorf / fluxui-avatar example snippets


// config/fluxui-avatar.php

return [
    // 'spatie' or 'disk'
    'driver' => env('FLUXUI_AVATAR_DRIVER', 'disk'),

    // Spatie driver settings
    'spatie_collection_name' => 'avatars',

    // Disk driver settings
    'disk'      => env('FLUXUI_AVATAR_DISK', 'public'),
    'directory' => 'avatars',
    'column'    => 'avatar_path', // DB column on your User model

    // Validation
    'accepted_types'  => ['jpg', 'jpeg', 'png', 'webp'],
    'max_file_size'   => 2048, // in KB

    // Default avatar URL (null uses Flux UI's built-in fallback)
    'default_avatar' => null,
];

$table->string('avatar_path')->nullable();

use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;

class User extends Authenticatable implements HasMedia
{
    use InteractsWithMedia;

    public function registerMediaCollections(): void
    {
        $this->addMediaCollection('avatars')->singleFile();
    }
}

$viewFactory->prependNamespace('flux', __DIR__.'/../resources/views/components');
bash
php artisan vendor:publish --tag=fluxui-avatar-config