Skip to content
Snippets Groups Projects
Verified Commit 81ef6bf9 authored by Sofiane Lasri's avatar Sofiane Lasri
Browse files

feat: add public layout and index controller, refactor models to use custom base model

- Create a new public layout in `resources/views/layouts/public.blade.php`.
- Implement `IndexController` in `app/Http/Controllers/Public/IndexController.php` to handle the main page logic.
- Introduce `CustomBaseModel` for caching model queries in `app/Models/CustomBaseModel.php`.
- Refactor existing models (CreationPicture, SocialMediaLink, Prestation, Event, Creation, Category) to extend `CustomBaseModel`.
- Update routes to use `IndexController` for the homepage.
- Move the main index view to `resources/views/public/index.blade.php` and adapt it to use the new layout and controller data.
parent 2ca8ad4d
Branches
No related tags found
1 merge request!13Resolve "Créer la page d'accueil"
Pipeline #681 passed
<?php
namespace App\Http\Controllers\Public;
use App\Http\Controllers\Controller;
use App\Models\Category;
use App\Models\SocialMediaLink;
use Illuminate\View\View;
class IndexController extends Controller
{
public function __invoke(): View
{
$socialMediaLinks = SocialMediaLink::all();
$categories = Category::all();
return view('public.index', compact('socialMediaLinks', 'categories'));
}
}
......@@ -3,10 +3,9 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Category extends Model
class Category extends CustomBaseModel
{
use HasFactory;
......
......
......@@ -3,11 +3,10 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Creation extends Model
class Creation extends CustomBaseModel
{
use HasFactory;
......
......
......@@ -3,10 +3,9 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class CreationPicture extends Model
class CreationPicture extends CustomBaseModel
{
use HasFactory;
......
......
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
class CustomBaseModel extends Model
{
/**
* Get all records from the model. If the records are already cached, return them.
*
* @param array $columns
*/
public static function all($columns = ['*']): Collection
{
return Cache::remember(static::class, 3600, function () use ($columns) {
return parent::all($columns);
});
}
}
......@@ -3,10 +3,9 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Event extends Model
class Event extends CustomBaseModel
{
use HasFactory;
......
......
......@@ -3,10 +3,9 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Prestation extends Model
class Prestation extends CustomBaseModel
{
use HasFactory;
......
......
......@@ -3,9 +3,8 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class SocialMediaLink extends Model
class SocialMediaLink extends CustomBaseModel
{
use HasFactory;
......
......
<!DOCTYPE html>
<html lang="{{ config('app.locale') }}">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@yield('title', 'Rann Graphic Design')</title>
<link rel="icon" type="image/svg+xml" href="{{ asset('favicon.svg') }}"/>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=PT+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap"
rel="stylesheet">
@vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<body>
<div class="HeroSection h-96 w-100 position-relative">
<div class="container mx-auto px-2">
<!-- Navbar -->
<div class="Navbar h-32 flex items-center">
<div class="flex justify-between items-center w-full">
<div class="flex justify-start items-center gap-32 ">
<x-public.rann-logo height="4rem" role="image"/>
<div class="flex items-center gap-12">
<a href="{{ route('index') }}" class="text-xl font-bold">Accueil</a>
<a href="#" class="text-xl font-bold">Prestations</a>
<a href="#" class="text-xl font-bold">Portfolio</a>
<a href="#" class="text-xl font-bold">Évènements</a>
<a href="#" class="text-xl font-bold">Me contacter</a>
<x-public.button tag="a" href="#">Boutique</x-public.button>
</div>
</div>
<div class="items-center gap-4 flex">
@foreach(\App\Models\SocialMediaLink::all() as $socialMediaLink)
<a href="{{ $socialMediaLink->url }}" target="_blank" rel="noopener noreferrer">
<x-font-awesome :icon="$socialMediaLink->icon_name" type="brands" class="w-5 h-5"/>
</a>
@endforeach
</div>
</div>
</div>
<!-- Hero Content -->
<div class="py-8 justify-center gap-32 items-center inline-flex w-full">
<div class="MetaContainer flex-col shrink-0 w-[33rem]">
<div class="h-96 grow shrink-0 basis-0 flex-col justify-center items-start flex">
<div class="flex-col justify-start items-start gap-24 flex relative">
<x-public.star
class="w-12 left-[-120.23px] top-[-95.50px] absolute origin-top-left rotate-[6.66deg]"/>
<x-public.star
class="w-16 left-[-82px] top-[-26.29px] absolute origin-top-left rotate-[-21.43deg]"/>
<div class="flex-col justify-start items-start flex">
<div class="self-stretch justify-start items-center gap-4 inline-flex">
<div class="text-3xl font-normal">
Hello ! Je suis Roxanna Valtre,
</div>
<x-public.arrow class="w-28 h-9"/>
</div>
<div class="text-6xl font-bold">
Designer Graphique.
</div>
</div>
<x-public.button size="large" tag="a" href="#" class="items-center gap-8 inline-flex">
<img class="w-10 h-10" src="{{Vite::asset("resources/images/public/waving-hand.avif")}}"
alt="Emoji de main qui salue" loading="eager"/>
<div class="flex-col justify-center items-start inline-flex">
<div class="leading-6 font-bold">Un projet en
tête ?
</div>
<div class="font-normal">
N’hésitez pas à me contacter !
</div>
</div>
</x-public.button>
</div>
</div>
<div class="flex flex-col gap-4 self-stretch relative">
<x-public.star class="w-20 left-[552px] top-[49.80px] absolute origin-top-left rotate-[-1.90deg]"/>
<div class="flex flex-col">
<div class="text-2xl font-bold">Mes
spécialisations
</div>
<div class="text-muted text-sm font-normal">
Cliquez sur une spécialité pour la masquer ;)
</div>
</div>
<div class="items-center gap-2 flex flex-wrap">
@foreach(\App\Models\Category::all() as $category)
<x-public.button :variant="$category->color"
name="{{ $category->slug }}">
{{ $category->nameTranslationKey->getTranslation(config('app.locale')) }}
</x-public.button>
@endforeach
</div>
</div>
</div>
<div class="Creations grow w-full aspect-[72/59] relative bg-green/15">
{{--<img class="Image3 w-80 h-36 left-[56.21px] top-[487.98px] absolute rounded-2xl"
src="https://via.placeholder.com/319x137"/>
<img class="Image2 w-72 h-96 left-0 top-[50.13px] absolute rounded-2xl"
src="https://via.placeholder.com/275x374"/>
<img class="Image5 w-72 h-72 left-[602.94px] top-[342.71px] absolute rounded-2xl"
src="https://via.placeholder.com/282x282"/>
<img class="Image4 w-96 h-96 left-[292.27px] top-[22.51px] absolute rounded-2xl"
src="https://via.placeholder.com/360x489"/>
<img class="Image6 w-48 h-72 left-[661.20px] top-0 absolute rounded-2xl"
src="https://via.placeholder.com/193x291"/>--}}
</div>
</div>
</div>
<img class="HeroGrid w-100 left-0 top-0 absolute -z-10" alt="Image de fond"
src="{{Vite::asset("resources/images/public/hero-grid.avif")}}"/>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="{{ config('app.locale') }}">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@yield('title', 'Rann Graphic Design')</title>
<link rel="icon" type="image/svg+xml" href="{{ asset('favicon.svg') }}"/>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=PT+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap"
rel="stylesheet">
@vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<body>
@yield('content')
</body>
</html>
\ No newline at end of file
@extends('layouts.public')
@section('content')
<div class="HeroSection h-96 w-100 position-relative">
<div class="container mx-auto px-2">
<!-- Navbar -->
<div class="Navbar h-32 flex items-center">
<div class="flex justify-between items-center w-full">
<div class="flex justify-start items-center gap-32 ">
<x-public.rann-logo height="4rem" role="image"/>
<div class="flex items-center gap-12">
<a href="{{ route('index') }}" class="text-xl font-bold">Accueil</a>
<a href="#" class="text-xl font-bold">Prestations</a>
<a href="#" class="text-xl font-bold">Portfolio</a>
<a href="#" class="text-xl font-bold">Évènements</a>
<a href="#" class="text-xl font-bold">Me contacter</a>
<x-public.button tag="a" href="#">Boutique</x-public.button>
</div>
</div>
<div class="items-center gap-4 flex">
@foreach($socialMediaLinks as $socialMediaLink)
<a href="{{ $socialMediaLink->url }}" target="_blank" rel="noopener noreferrer">
<x-font-awesome :icon="$socialMediaLink->icon_name" type="brands" class="w-5 h-5"/>
</a>
@endforeach
</div>
</div>
</div>
<!-- Hero Content -->
<div class="py-8 justify-center gap-32 items-center inline-flex w-full">
<div class="MetaContainer flex-col shrink-0 w-[33rem]">
<div class="h-96 grow shrink-0 basis-0 flex-col justify-center items-start flex">
<div class="flex-col justify-start items-start gap-24 flex relative">
<x-public.star
class="w-12 left-[-120.23px] top-[-95.50px] absolute origin-top-left rotate-[6.66deg]"/>
<x-public.star
class="w-16 left-[-82px] top-[-26.29px] absolute origin-top-left rotate-[-21.43deg]"/>
<div class="flex-col justify-start items-start flex">
<div class="self-stretch justify-start items-center gap-4 inline-flex">
<div class="text-3xl font-normal">
Hello ! Je suis Roxanna Valtre,
</div>
<x-public.arrow class="w-28 h-9"/>
</div>
<div class="text-6xl font-bold">
Designer Graphique.
</div>
</div>
<x-public.button size="large" tag="a" href="#" class="items-center gap-8 inline-flex">
<img class="w-10 h-10" src="{{Vite::asset("resources/images/public/waving-hand.avif")}}"
alt="Emoji de main qui salue" loading="eager"/>
<div class="flex-col justify-center items-start inline-flex">
<div class="leading-6 font-bold">Un projet en
tête ?
</div>
<div class="font-normal">
Nhésitez pas à me contacter !
</div>
</div>
</x-public.button>
</div>
</div>
<div class="flex flex-col gap-4 self-stretch relative">
<x-public.star
class="w-20 left-[552px] top-[49.80px] absolute origin-top-left rotate-[-1.90deg]"/>
<div class="flex flex-col">
<div class="text-2xl font-bold">Mes
spécialisations
</div>
<div class="text-muted text-sm font-normal">
Cliquez sur une spécialité pour la masquer ;)
</div>
</div>
<div class="items-center gap-2 flex flex-wrap">
@foreach($categories as $category)
<x-public.button :variant="$category->color"
name="{{ $category->slug }}">
{{ $category->nameTranslationKey->getTranslation(config('app.locale')) }}
</x-public.button>
@endforeach
</div>
</div>
</div>
<div class="Creations grow w-full aspect-[72/59] relative bg-green/15">
{{--<img class="Image3 w-80 h-36 left-[56.21px] top-[487.98px] absolute rounded-2xl"
src="https://via.placeholder.com/319x137"/>
<img class="Image2 w-72 h-96 left-0 top-[50.13px] absolute rounded-2xl"
src="https://via.placeholder.com/275x374"/>
<img class="Image5 w-72 h-72 left-[602.94px] top-[342.71px] absolute rounded-2xl"
src="https://via.placeholder.com/282x282"/>
<img class="Image4 w-96 h-96 left-[292.27px] top-[22.51px] absolute rounded-2xl"
src="https://via.placeholder.com/360x489"/>
<img class="Image6 w-48 h-72 left-[661.20px] top-0 absolute rounded-2xl"
src="https://via.placeholder.com/193x291"/>--}}
</div>
</div>
</div>
<img class="HeroGrid w-100 left-0 top-0 absolute -z-10" alt="Image de fond"
src="{{Vite::asset("resources/images/public/hero-grid.avif")}}"/>
</div>
@endsection
......@@ -8,14 +8,13 @@
use App\Http\Controllers\Admin\PrestationController;
use App\Http\Controllers\Admin\SettingsController;
use App\Http\Controllers\Admin\SocialMediaLinksController;
use App\Http\Controllers\Public\IndexController;
use App\Http\Middleware\RedirectIfUserExistsMiddleware;
use Illuminate\Support\Facades\Route;
use Laravel\Fortify\Features;
use Laravel\Fortify\Http\Controllers\RegisteredUserController;
Route::get('/', function () {
return view('index');
})->name('index');
Route::get('/', IndexController::class)->name('index');
if (Features::enabled(Features::registration())) {
Route::get('/register', [RegisteredUserController::class, 'create'])
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment