Skip to content

Commit d7a169d

Browse files
committed
updated vuetify to latest version 1.2.1~ and added some useful helper functions in core component
1 parent d846609 commit d7a169d

File tree

3 files changed

+87
-5
lines changed

3 files changed

+87
-5
lines changed

app/Components/Core/Utilities/Helpers.php

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,86 @@ public static function hasWebProtocol(string $string) : bool
184184

185185
return !empty($d['scheme']);
186186
}
187+
188+
/**
189+
* helper to make a strung slug
190+
*
191+
* @param string $string
192+
* @param string $sep
193+
* @return string
194+
*/
195+
public static function stringToSlug(string $string, $sep = '-'): string
196+
{
197+
return strtolower(str_replace(['-'],$sep,static::cleanString($string)));
198+
}
199+
200+
/**
201+
* clean string, remove special characters
202+
*
203+
* @param string $string
204+
* @return string
205+
*/
206+
public static function cleanString(string $string): string
207+
{
208+
$string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.
209+
$string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
210+
return preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
211+
}
212+
213+
/**
214+
* normalize an input to array type. If its a string, then it might be comma
215+
* separated value so we will make it to array.
216+
*
217+
* @author darryldecode <darrylfernandez.com>
218+
* @since v1.0
219+
*
220+
* @param $input
221+
*
222+
* @return array
223+
*/
224+
public static function normalizeToArray($input): array
225+
{
226+
if(is_array($input)) return $input;
227+
if(is_string($input)) return explode(',',$input);
228+
if(is_object($input)) return (array)$input;
229+
return [];
230+
}
231+
232+
/**
233+
* helper to get the real client IP address
234+
*
235+
* @author darryldecode <darrylfernandez.com>
236+
* @since v1.0
237+
* @return array|false|string
238+
*/
239+
public static function getClientIpAddress()
240+
{
241+
return getenv('HTTP_CLIENT_IP')?:
242+
getenv('HTTP_X_FORWARDED_FOR')?:
243+
getenv('HTTP_X_FORWARDED')?:
244+
getenv('HTTP_FORWARDED_FOR')?:
245+
getenv('HTTP_FORWARDED')?:
246+
getenv('REMOTE_ADDR');
247+
}
248+
249+
/**
250+
* @author darryldecode <darrylfernandez.com>
251+
* @since v1.0
252+
*
253+
* @param $key
254+
* @param $value
255+
*
256+
* @return bool
257+
*/
258+
public static function updateEnv(string $key,string $value)
259+
{
260+
$envFile = app()->environmentFilePath();
261+
$str = file_get_contents($envFile);
262+
$oldValue = env($key);
263+
$str = str_replace("{$key}={$oldValue}", "{$key}={$value}", $str);
264+
$fp = fopen($envFile, 'w');
265+
fwrite($fp, $str);
266+
fclose($fp);
267+
return true;
268+
}
187269
}

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"moment": "^2.21.0",
2424
"vue-router": "^3.0.1",
2525
"vue-spinner": "^1.0.2",
26-
"vuetify": "^1.1.8",
26+
"vuetify": "^1.2.1",
2727
"vuex": "^3.0.1"
2828
}
29-
}
29+
}

0 commit comments

Comments
 (0)