Skip to content
This repository has been archived by the owner on Oct 13, 2024. It is now read-only.

Commit

Permalink
Show data in the home page
Browse files Browse the repository at this point in the history
  • Loading branch information
WillianDamasceno committed Jun 8, 2024
1 parent f280104 commit 2762c62
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
48 changes: 48 additions & 0 deletions resources/views/home.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
@extends('components.layouts.app')

@section('content')
<main class="container grid grid-cols-1 gap-4 p-8">
@foreach ($users as $user)
<article class="relative flex justify-between rounded-md bg-base-200/50 px-8 py-4 shadow">
<div>
<div>{{ $user->name }}</div>
<div>{{ $user->email }}</div>
</div>

<button popovertarget="popover-{{ $user->id }}" class="hover:text-primary">Ver pets</button>
<div id="popover-{{ $user->id }}" popover
class="w-[min(100vw-2rem,600px)] rounded-xl bg-base-200/50 p-12 shadow"
>
@foreach ($user->pets as $pet)
<div class="flex flex-col justify-between">
<h2 class="text-lg font-bold">Dados do pet</h2>
<div>Nome: {{ $pet->name }}</div>
<div>Nascimento: {{ $pet->born }}</div>
<div>Tipo: {{ $pet->type }}</div>

@if (!empty($pet->vaccines) && $pet->vaccines !== '_' && $pet->vaccines)
@php
$vaccines = explode(',', $pet->vaccines);
@endphp
@if (count($vaccines) > 1)
<h2 class="mt-8 text-lg font-bold">Vacinas</h2>
<div>
@foreach ($vaccines as $vaccine)
@php
[$name, $date] = explode('-', $vaccine);
@endphp
<div class="flex items-center">
<div class="mr-2">{{ $name }}</div>
<div>{{ $date }}</div>
</div>
@endforeach
</div>
@endif
@endif
</div>
@endforeach
</div>
</article>
@endforeach
</main>
@endsection
5 changes: 0 additions & 5 deletions resources/views/welcome.blade.php

This file was deleted.

7 changes: 6 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<?php

use App\Models\Pet;
use App\Models\User;
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
return view('welcome');
return view('home', [
'users' => User::all(),
'petQuantity' => Pet::has('user')->count(),
]);
});

0 comments on commit 2762c62

Please sign in to comment.