PHP code example of silvanite / nova-field-cloudinary

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

    

silvanite / nova-field-cloudinary example snippets


// config/filesystem.php
return [
    ...
    'disks' => [
        ...
        'cloudinary' => [
            'driver' => 'cloudinary',
            'api_key' => env('CLOUDINARY_API_KEY'),
            'api_secret' => env('CLOUDINARY_API_SECRET'),
            'cloud_name' => env('CLOUDINARY_CLOUD_NAME'),
        ]
    ]
];

use Silvanite\NovaFieldCloudinary\Fields\CloudinaryImage;

public function fields(Request $request)
{
    return [
        ...
        CloudinaryImage::make('Profile Photo'),
    ]
}

// Using the helper (with transformation)

return cloudinary_image($this->profile_photo, [
    "width" => 200,
    "height" => 200,
    "crop" => "fill",
    "gravity" => "auto",
])

// Using the Storage Facade (without transformation)

return Storage::disk('cloudinary')->url($this->profile_photo);

// Using the Storage Facade (with transformation)

return Storage::disk('cloudinary')->url([
    'public_id' => $this->profile_photo,
    'options' => [
        "width" => 200,
        "height" => 200,
        "crop" => "fill",
        "gravity" => "auto",
    ],
])

use Silvanite\NovaFieldCloudinary\Fields\CloudinaryAudio;

public function fields(Request $request)
{
    return [
        ...
        CloudinaryAudio::make('Audio Source'),
    ]
}

// Using the audio helper

return cloudinary_audio($this->audio_source);

// Using the Storage Facade

return Storage::disk('cloudinary')->url([
    'public_id' => $this->audio_source,
    'options' => [
        "resource_type" => "video",
    ],
])

use Silvanite\NovaFieldCloudinary\Fields\CloudinaryVideo;

public function fields(Request $request)
{
    return [
        ...
        CloudinaryVideo::make('Video Source'),
    ]
}

// Using the video helper

return cloudinary_video($this->video_source);

// Using the Storage Facade

return Storage::disk('cloudinary')->url([
    'public_id' => $this->audio_source,
    'options' => [
        "resource_type" => "video",
    ],
])

use Silvanite\NovaFieldCloudinary\Fields\CloudinaryFile;

public function fields(Request $request)
{
    return [
        ...
        CloudinaryFile::make('Document'),
    ]
}