storage\app\public
1001.jpg
404.jpg
Router:
Route::get('/get-flight-image/{image_name}',[FlightController::class,'getFlightImage'])->name('flight.get-flight-image');
1001.jpg
404.jpg
Router:
Route::get('/get-flight-image/{image_name}',[FlightController::class,'getFlightImage'])->name('flight.get-flight-image');
Controller:
public function getFlightImage($image_name) {
$imagePath = Storage::disk('public')->get($image_name);
return $imagePath;
}
OR
public function getFlightImage($image_name) {
if (Storage::disk('public')->exists($image_name)) {
return Storage::disk('public')->get($image_name);
}
if (Storage::disk('public')->missing($image_name)) {
return Storage::disk('public')->get('404.jpg');
}
}
inde.blade.php
public function getFlightImage($image_name) {
$imagePath = Storage::disk('public')->get($image_name);
return $imagePath;
}
OR
public function getFlightImage($image_name) {
if (Storage::disk('public')->exists($image_name)) {
return Storage::disk('public')->get($image_name);
}
if (Storage::disk('public')->missing($image_name)) {
return Storage::disk('public')->get('404.jpg');
}
}
inde.blade.php
<img src="{{ route('flight.get-flight-image',['image_name'=>'1001.jpg']) }}" alt="">
0 comments:
Post a Comment