0

i try to upload avatar photo on my user model, using laravel nova Fields\Avatar applying the simpliest code, but it return 0 value on my database, the disk already set to s3 disk in filesystem also nova disk. is it something missing or i skip some of process?

oh and by the way, i already installing league/flysystem-aws-s3-v3. but not resolve it at all.

here's my code :

my nova.php config

/*
    |--------------------------------------------------------------------------
    | Nova Storage Disk
    |--------------------------------------------------------------------------
    |
    | This configuration option allows you to define the default disk that
    | will be used to store files using the Image, File, and other file
    | related field types. You're welcome to use any configured disk.
    |
     */

    'storage_disk' => env('NOVA_STORAGE_DISK', 's3'),

my filesystems.php config

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default Filesystem Disk
    |--------------------------------------------------------------------------
    |
    | Here you may specify the default filesystem disk that should be used
    | by the framework. The "local" disk, as well as a variety of cloud
    | based disks are available to your application. Just store away!
    |
    */

    'default' => env('FILESYSTEM_DISK', 's3'),

    /*
    |--------------------------------------------------------------------------
    | Filesystem Disks
    |--------------------------------------------------------------------------
    |
    | Here you may configure as many filesystem "disks" as you wish, and you
    | may even configure multiple disks of the same driver. Defaults have
    | been set up for each driver as an example of the required values.
    |
    | Supported Drivers: "local", "ftp", "sftp", "s3"
    |
    */

    'disks' => [
        's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),
            'endpoint' => env('AWS_ENDPOINT'),
            'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
            'visibility' => 'public',
            'throw' => false
        ],

    ],

    /*
    |--------------------------------------------------------------------------
    | Symbolic Links
    |--------------------------------------------------------------------------
    |
    | Here you may configure the symbolic links that will be created when the
    | `storage:link` Artisan command is executed. The array keys should be
    | the locations of the links and the values should be their targets.
    |
    */

    'links' => [
        public_path('storage') => storage_path('app/public'),
    ],

];

my resource fields nova

/**
     * Get the fields displayed by the resource.
     *
     * @param  \Laravel\Nova\Http\Requests\NovaRequest  $request
     * @return array
     */
    public function fields(NovaRequest $request)
    {
        return [
            Fields\Avatar::make('Avatar'),
            Fields\Text::make('Name')->sortable()->rules(['required']),
            Fields\Email::make('Email')->rules(['required', 'email']),
            Fields\Text::make('Phone')->rules(['required']),

            (new Panel('Job Position', $this->jobFields()))->limit(3),
            (new Panel('Employee Information', $this->employeeFields()))->limit(2),
            (new Panel('Payroll Information', $this->payrollFields()))->limit(2),
            (new Panel('Date Information', $this->dateFields())),
            (new Panel('Authentication', $this->authenticationFields())),
        ];
    }

i excpected the outcome of avatar fields is returning the asset that i upload on my s3 disk, but it happen like this

the preview of my avatar

the database value on avatar column

1 Answer 1

3

solved guys, i just forget to set true of throw key on my filesystems.php :D

the actual error appear suddenly.

this config that i forget :

    's3' => [
                'driver' => 's3',
                'key' => env('AWS_ACCESS_KEY_ID'),
                'secret' => env('AWS_SECRET_ACCESS_KEY'),
                'region' => env('AWS_DEFAULT_REGION'),
                'bucket' => env('AWS_BUCKET'),
                'url' => env('AWS_URL'),
                'endpoint' => env('AWS_ENDPOINT'),
                'visibility' => 'public',
                'throw' => true // <- this line has to be true for debugging
            ],
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.