Skip to content

Commit 65be7db

Browse files
committed
add config
1 parent 54285a7 commit 65be7db

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

config/cloudinary.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Laravel Cloudinary package.
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
return [
11+
12+
/*
13+
|--------------------------------------------------------------------------
14+
| Cloudinary Configuration
15+
|--------------------------------------------------------------------------
16+
|
17+
| An HTTP or HTTPS URL to notify your application (a webhook) when the process of uploads, deletes, and any API
18+
| that accepts notification_url has completed.
19+
|
20+
|
21+
*/
22+
'notification_url' => env('CLOUDINARY_NOTIFICATION_URL'),
23+
24+
/*
25+
|--------------------------------------------------------------------------
26+
| Cloudinary Configuration
27+
|--------------------------------------------------------------------------
28+
|
29+
| Here you may configure your Cloudinary settings. Cloudinary is a cloud hosted
30+
| media management service for all file uploads, storage, delivery and transformation needs.
31+
|
32+
|
33+
*/
34+
'cloud_url' => env('CLOUDINARY_URL'),
35+
36+
/**
37+
* Upload Preset From Cloudinary Dashboard
38+
*/
39+
'upload_preset' => env('CLOUDINARY_UPLOAD_PRESET'),
40+
41+
/**
42+
* Route to get cloud_image_url from Blade Upload Widget
43+
*/
44+
'upload_route' => env('CLOUDINARY_UPLOAD_ROUTE'),
45+
46+
/**
47+
* Controller action to get cloud_image_url from Blade Upload Widget
48+
*/
49+
'upload_action' => env('CLOUDINARY_UPLOAD_ACTION'),
50+
];

src/CloudinaryServiceProvider.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,33 @@ public function boot(): void
3737

3838
return new FilesystemAdapter(new Filesystem($adapter, $config), $adapter, $config);
3939
});
40+
41+
$this->publishes([
42+
__DIR__.'/../config/cloudinary.php' => config_path('cloudinary.php'),
43+
], 'cloudinary-config');
4044
}
4145

4246
public function register(): void
4347
{
48+
$this->mergeConfigFrom(__DIR__.'/../config/cloudinary.php', 'cloudinary');
49+
4450
$this->app->singleton(Cloudinary::class, function ($app) {
45-
return new Cloudinary($app['config']->get('cloudinary'));
51+
$config = $app['config']->get('filesystems.disks.cloudinary');
52+
53+
if (isset($config['url'])) {
54+
return new Cloudinary($config['url']);
55+
}
56+
57+
return new Cloudinary([
58+
'cloud' => [
59+
'cloud_name' => $config['cloud'],
60+
'api_key' => $config['key'],
61+
'api_secret' => $config['secret'],
62+
],
63+
'url' => [
64+
'secure' => $config['secure'] ?? false,
65+
],
66+
]);
4667
});
4768
}
4869
}

0 commit comments

Comments
 (0)