77use Exception ;
88use Tamedevelopers \Support \Str ;
99use Tamedevelopers \Support \Tame ;
10+ use Tamedevelopers \Support \Server ;
1011use Tamedevelopers \File \ImageCompress ;
1112use Tamedevelopers \File \ImageWatermark ;
1213use Tamedevelopers \Validator \Validator ;
@@ -115,7 +116,7 @@ public function save($closure = null)
115116 * @param string $watermarkSource The path to the watermark image.
116117 *
117118 * @param string $position The position of the watermark. - Default is 'bottom-right'
118- * - ['center', 'bottom-right', 'bottom-left', 'top-right', 'top-left']
119+ * ['center', 'bottom-right', 'bottom-left', 'top-right', 'top-left']
119120 *
120121 * @param int $padding Padding in pixels (applied to all positions except 'center')
121122 *
@@ -185,6 +186,30 @@ public function compress()
185186 return $ this ;
186187 }
187188
189+ /**
190+ * Change base directory
191+ *
192+ * @param string $directory
193+ * @return $this
194+ */
195+ public function baseDir ($ directory )
196+ {
197+ // clean the path given
198+ $ baseDirName = trim ((string ) $ directory , '\/ ' );
199+
200+ // base domain path
201+ $ this ->config ['baseUrl ' ] = Server::cleanServerPath (
202+ domain ($ baseDirName )
203+ );
204+
205+ // trim string
206+ $ this ->config ['baseDir ' ] = Server::cleanServerPath (
207+ base_path ($ baseDirName )
208+ );
209+
210+ return $ this ;
211+ }
212+
188213 /**
189214 * Change driver type
190215 *
@@ -235,13 +260,12 @@ public function structure($structure)
235260 /**
236261 * Upload size in mb
237262 *
238- * @param int|string|null $size
263+ * @param int|string $size
239264 * [optional] Default is (2mb)
240265 *
241- *
242266 * @return $this
243267 */
244- public function size ($ size = null )
268+ public function size ($ size )
245269 {
246270 $ this ->config ['size ' ] = Tame::sizeToBytes (
247271 !empty ($ size ) && (int ) $ size >= 1024
@@ -255,10 +279,10 @@ public function size($size = null)
255279 /**
256280 * Upload limit
257281 *
258- * @param int|string|null $limit
282+ * @param int|string $limit
259283 * @return $this
260284 */
261- public function limit ($ limit = null )
285+ public function limit ($ limit )
262286 {
263287 $ this ->config ['limit ' ] = self ::numbericToInt ($ limit ) ?: 1 ;
264288
@@ -268,13 +292,13 @@ public function limit($limit = null)
268292 /**
269293 * Set width
270294 *
271- * @param int|string|null $width
295+ * @param int|string $width
272296 * @param bool $width - Default is `true`
273297 * [optional] Set to false will make size equal to or greather than
274298 *
275299 * @return $this
276300 */
277- public function width ($ width = null , ?bool $ actual = true )
301+ public function width ($ width , ?bool $ actual = true )
278302 {
279303 $ this ->config ['width ' ] = [
280304 'size ' => self ::numbericToInt ($ width ),
@@ -287,13 +311,13 @@ public function width($width = null, ?bool $actual = true)
287311 /**
288312 * Set Height
289313 *
290- * @param int|string|null $height
314+ * @param int|string $height
291315 * @param bool $width - Default is `true`
292316 * [optional] Set to false will make size equal to or greather than
293317 *
294318 * @return $this
295319 */
296- public function height ($ height = null , ?bool $ actual = true )
320+ public function height ($ height , ?bool $ actual = true )
297321 {
298322 $ this ->config ['height ' ] = [
299323 'size ' => self ::numbericToInt ($ height ),
@@ -306,10 +330,13 @@ public function height($height = null, ?bool $actual = true)
306330 /**
307331 * Set Mime Type
308332 *
309- * @param string|null $mime
333+ * @param string $mime
334+ * [available keys]
335+ * - video|audio|file|image|general_image|general_media|general_file
336+ *
310337 * @return $this
311338 */
312- public function mime ($ mime = null )
339+ public function mime ($ mime )
313340 {
314341 $ this ->config ['mime ' ] = $ mime ;
315342
@@ -390,6 +417,7 @@ public function isCompleted()
390417 * Get First Element of Uploads
391418 *
392419 * @param string|null $mode
420+ * - [name, path, url]
393421 *
394422 * @return array|string|null
395423 */
@@ -403,11 +431,19 @@ public function first($mode = null)
403431 /**
404432 * Get all Element of Uploads
405433 *
434+ * @param string|null $mode
435+ * - [name, path, url]
436+ *
406437 * @return array|null
407438 */
408- public function get ()
439+ public function get ($ mode = null )
409440 {
410- return self ::getUploads ($ this ->uploads );
441+ $ data = self ::getUploads ($ this ->uploads );
442+ if (is_null ($ mode )){
443+ return $ data ;
444+ }
445+
446+ return array_column ($ data , $ mode );
411447 }
412448
413449 /**
0 commit comments