PHP code example of bbs-lab / nova-cloudinary-field

1. Go to this page and download the library: Download bbs-lab/nova-cloudinary-field 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/ */

    

bbs-lab / nova-cloudinary-field example snippets




declare(strict_types=1);

return [

    'default' => [
        'cloud' => env('NOVA_CLOUDINARY_DEFAULT_CLOUD'),
        'username' => env('NOVA_CLOUDINARY_DEFAULT_USERNAME'),
        'key' => env('NOVA_CLOUDINARY_DEFAULT_KEY'),
        'secret' => env('NOVA_CLOUDINARY_DEFAULT_SECRET'),
    ],

];



namespace App\Nova;

declare(strict_types=1);

namespace App\Nova;

class BlogPost extends Resource
{
    // ...
    
    public function fields(Request $request)
    {
        return [
            // ...

            Cloudinary::make('Image'),

            // ...
        ];
    }
    
}



declare(strict_types=1);

namespace App\Nova;

use BBSLab\CloudinaryField\Cloudinary;

class BlogPost extends Resource
{
    // ...
    
    public function fields(Request $request)
    {
        return [
            // ...

            Cloudinary::make('Image')
                ->multiple(),

            // ...
        ];
    }
    
}



declare(strict_types=1);

namespace App\Nova;

use BBSLab\CloudinaryField\Cloudinary;

class BlogPost extends Resource
{
    // ...
    
    public function fields(Request $request)
    {
        return [
            // ...

            Cloudinary::make('Image')
                ->multiple()
                ->limit(10),

            // ...
        ];
    }
    
}



declare(strict_types=1);

namespace App\Nova;

use BBSLab\CloudinaryField\Cloudinary;use Laravel\Nova\Http\Requests\NovaRequest;

class BlogPost extends Resource
{
    // ...
    
    public function fields(Request $request)
    {
        return [
            // ...

            Cloudinary::make('Image')
                ->configureUsing(function (NovaRequest $request) {
                    return [
                        'cloud' => 'my_cloud',
                        'username' => 'my_username',
                        'key' => 'my_key',
                        'secret' => 'my_secret',
                    ];
                });

            // ...
        ];
    }
    
}



declare(strict_types=1);

namespace App\Nova;

use BBSLab\CloudinaryField\Cloudinary;
use Laravel\Nova\Fields\Boolean;
use Laravel\Nova\Fields\FormData;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;

class BlogPost extends Resource
{
    // ...

    public function fields(NovaRequest $request): array
    {
        return [
            ID::make()->sortable(),

            Text::make('Title')
                ->sortable()
                ->rules('red');
                    } else {
                        $field->hide();
                    }
                }),
        ];
    }
}



declare(strict_types=1);

namespace App\Providers;

use BBSLab\CloudinaryField\NovaCloudinary;
use Laravel\Nova\NovaApplicationServiceProvider;

class NovaServiceProvider extends NovaApplicationServiceProvider
{
    // ...

    public function tools(): array
    {
        return [
            NovaCloudinary::make(),
        ];
    }
}

bash
php artisan vendor:publish --provider="BBSLab\CloudinaryField\CloudinaryFieldServiceProvider" --tag="config"