How to add custom method in laravel library

331 Views Asked by At

How to add custom method in laravel library which is not removed when laravel version update or PHP version update, I am using Cloudinary library "https://github.com/jrm2k6/cloudder" , I need to add a custom function which is not included in the library.

 public function uploadLargeVideo($source, $publicId = null, $uploadOptions = array(), $tags = array())
{
    $options = array_merge($uploadOptions, ['resource_type' => 'video']);
    return $this->upload_large($source, $publicId,  $options, $tags);
}
1

There are 1 best solutions below

0
On

You can create a new class extending the class provided by the library.

<?php

namespace App\Support;

use JD\Cloudder\Facades\Cloudder as BaseCloudder;

class Cloudder extends BaseCloudder
{
    // add your methods here
}

then use App\Support\Cloudder instead of JD\Cloudder\Facades\Cloudder in your controller.