|
1 | 1 | <div align="center"> |
2 | | - <h2> Laravel Cloudinary </h2> |
| 2 | + <h1> Laravel Cloudinary </h1> |
3 | 3 | </div> |
4 | 4 |
|
5 | 5 | <p align="center"> |
|
17 | 17 | </a> |
18 | 18 | </p> |
19 | 19 |
|
20 | | -> A Laravel Package for easily uploading, optimizing, transforming and delivering media files with Cloudinary. It provides a fluent and expressive API to easily attach your media files to Eloquent models. |
| 20 | +> A Laravel Package for uploading, optimizing, transforming and delivering media files with Cloudinary. It provides a fluent and expressive API to easily attach your media files to Eloquent models. |
21 | 21 |
|
22 | 22 |
|
23 | 23 | ## Usage |
24 | 24 |
|
25 | | -Upload a file to Cloudinary: |
| 25 | +Upload a file (Image, Video or any type of File) to Cloudinary: |
26 | 26 |
|
27 | 27 | ```php |
28 | 28 |
|
29 | | -``` |
30 | | - |
31 | | -Let me explain the fluent methods this package provides a bit here. |
32 | | -```php |
33 | | -/** |
34 | | - * This fluent method does all the dirty work of sending a POST request with the form data |
35 | | - * to Paystack Api, then it gets the authorization Url and redirects the user to Paystack |
36 | | - * Payment Page. We've abstracted all of it, so you don't have to worry about that. |
37 | | - * Just eat your cookies while coding! |
38 | | - */ |
39 | | -Paystack::getAuthorizationUrl()->redirectNow(); |
40 | | - |
41 | | -/** |
42 | | - * Alternatively, use the helper. |
43 | | - */ |
44 | | -paystack()->getAuthorizationUrl()->redirectNow(); |
45 | | - |
46 | | -/** |
47 | | - * This fluent method does all the dirty work of verifying that the just concluded transaction was actually valid, |
48 | | - * It verifies the transaction reference with Paystack Api and then grabs the data returned from Paystack. |
49 | | - * In that data, we have a lot of good stuff, especially the `authorization_code` that you can save in your db |
50 | | - * to allow for easy recurrent subscription. |
51 | | - */ |
52 | | -Paystack::getPaymentData(); |
53 | | - |
54 | | -/** |
55 | | - * Alternatively, use the helper. |
56 | | - */ |
57 | | -paystack()->getPaymentData(); |
58 | | - |
59 | 29 | /** |
60 | | - * This method gets all the customers that have performed transactions on your platform with Paystack |
61 | | - * @returns array |
62 | | - */ |
63 | | -Paystack::getAllCustomers(); |
64 | | - |
65 | | -/** |
66 | | - * Alternatively, use the helper. |
67 | | - */ |
68 | | -paystack()->getAllCustomers(); |
69 | | - |
70 | | - |
71 | | -/** |
72 | | - * This method gets all the plans that you have registered on Paystack |
73 | | - * @returns array |
74 | | - */ |
75 | | -Paystack::getAllPlans(); |
76 | | - |
77 | | -/** |
78 | | - * Alternatively, use the helper. |
79 | | - */ |
80 | | -paystack()->getAllPlans(); |
| 30 | +* Using the Cloudinary Facade |
| 31 | +*/ |
81 | 32 |
|
| 33 | +// Upload an Image File to Cloudinary with One line of Code |
| 34 | +$uploadedFileUrl = Cloudinary::upload($request->file('file')->getRealPath())->getSecurePath(); |
82 | 35 |
|
83 | | -/** |
84 | | - * This method gets all the transactions that have occurred |
85 | | - * @returns array |
86 | | - */ |
87 | | -Paystack::getAllTransactions(); |
| 36 | +// Upload an Video File to Cloudinary with One line of Code |
| 37 | +$uploadedFileUrl = Cloudinary::uploadVideo($request->file('file')->getRealPath())->getSecurePath(); |
88 | 38 |
|
89 | | -/** |
90 | | - * Alternatively, use the helper. |
91 | | - */ |
92 | | -paystack()->getAllTransactions(); |
| 39 | +// Upload any File to Cloudinary with One line of Code |
| 40 | +$uploadedFileUrl = Cloudinary::uploadFile($request->file('file')->getRealPath())->getSecurePath(); |
93 | 41 |
|
94 | 42 | /** |
95 | | - * This method generates a unique super secure cryptograhical hash token to use as transaction reference |
96 | | - * @returns string |
| 43 | + * This package also exposes a helper function you can use if you are not a fan of Facades |
| 44 | + * Shorter, expressive, fluent using the |
| 45 | + * cloudinary() function |
97 | 46 | */ |
98 | | -Paystack::genTranxRef(); |
99 | 47 |
|
100 | | -/** |
101 | | - * Alternatively, use the helper. |
102 | | - */ |
103 | | -paystack()->genTranxRef(); |
104 | | - |
105 | | - |
106 | | -/** |
107 | | -* This method creates a subaccount to be used for split payments |
108 | | -* @return array |
109 | | -*/ |
110 | | -Paystack::createSubAccount(); |
111 | | - |
112 | | -/** |
113 | | - * Alternatively, use the helper. |
114 | | - */ |
115 | | -paystack()->createSubAccount(); |
| 48 | +// Upload an Image File to Cloudinary with One line of Code |
| 49 | +$uploadedFileUrl = cloudinary()->upload($request->file('file')->getRealPath())->getSecurePath(); |
116 | 50 |
|
| 51 | +// Upload an Video File to Cloudinary with One line of Code |
| 52 | +$uploadedFileUrl = cloudinary()->uploadVideo($request->file('file')->getRealPath())->getSecurePath(); |
117 | 53 |
|
118 | | -/** |
119 | | -* This method fetches the details of a subaccount |
120 | | -* @return array |
121 | | -*/ |
122 | | -Paystack::fetchSubAccount(); |
| 54 | +// Upload any File to Cloudinary with One line of Code |
| 55 | +$uploadedFileUrl = cloudinary()->uploadFile($request->file('file')->getRealPath())->getSecurePath(); |
123 | 56 |
|
124 | 57 | /** |
125 | | - * Alternatively, use the helper. |
| 58 | + * You can also skip the Cloudinary Facade or helper method and laravel-ize your uploads by simply calling the |
| 59 | + * storeOnCloudinary() method on the file itself |
126 | 60 | */ |
127 | | -paystack()->fetchSubAccount(); |
128 | 61 |
|
| 62 | +// Store the uploaded file on Cloudinary |
| 63 | +$result = $request->file('file')->storeOnCloudinary(); |
129 | 64 |
|
130 | | -/** |
131 | | -* This method lists the subaccounts associated with your paystack account |
132 | | -* @return array |
133 | | -*/ |
134 | | -Paystack::listSubAccounts(); |
| 65 | +// Store the uploaded file on Cloudinary |
| 66 | +$result = $request->file->storeOnCloudinary(); |
135 | 67 |
|
136 | | -/** |
137 | | - * Alternatively, use the helper. |
138 | | - */ |
139 | | -paystack()->listSubAccounts(); |
| 68 | +// Store the uploaded file in the "lambogini" directory on Cloudinary |
| 69 | +$result = $request->file->storeOnCloudinary('lambogini'); |
140 | 70 |
|
141 | | - |
142 | | -/** |
143 | | -* This method Updates a subaccount to be used for split payments |
144 | | -* @return array |
145 | | -*/ |
146 | | -Paystack::updateSubAccount(); |
147 | | - |
148 | | -/** |
149 | | - * Alternatively, use the helper. |
150 | | - */ |
151 | | -paystack()->updateSubAccount(); |
| 71 | +// Store the uploaded file in the "lambogini" directory on Cloudinary with the filename "prosper" |
| 72 | +$result = $request->file->storeOnCloudinaryAs('lambogini', 'prosper'); |
152 | 73 | ``` |
153 | 74 |
|
154 | 75 | ## Installation |
|
0 commit comments