laravel if file exists code example
Example 1: check if file exists laravel
$file = public_path('storage/images/' . $value)
if(! file_exists($file)){
return asset('storage/images/default.png');
}
Example 2: laravel create new file if not exists
if (!file_exists('somefile.txt')) {
touch('somefile.txt', strtotime('-1 days'));
}