language files combined, settings fixed, "new" badge integrated
This commit is contained in:
@@ -4,20 +4,33 @@ namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Image;
|
||||
use Inertia\Inertia;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$locale = app()->getLocale();
|
||||
$translations = Lang::get('messages', [], $locale);
|
||||
$translations = array_merge(
|
||||
Lang::get('api', [], $locale),
|
||||
Lang::get('settings', [], $locale)
|
||||
);
|
||||
$galleryHeading = Setting::where('key', 'gallery_heading')->first()->value ?? 'Style Gallery';
|
||||
$newImageTimespanMinutes = Setting::where('key', 'new_image_timespan_minutes')->first()->value ?? 60; // Default to 60 minutes
|
||||
|
||||
$images = Image::all()->map(function ($image) use ($newImageTimespanMinutes) {
|
||||
$image->is_new = Carbon::parse($image->created_at)->diffInMinutes(Carbon::now()) <= $newImageTimespanMinutes;
|
||||
$image->path = 'storage/' . $image->path;
|
||||
return $image;
|
||||
});
|
||||
|
||||
return Inertia::render('Home', [
|
||||
'translations' => $translations,
|
||||
'galleryHeading' => $galleryHeading,
|
||||
'images' => $images,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user