Created
January 12, 2022 19:58
-
-
Save NandoKstroNet/7ca984ea2a77c1cc369555c6ce924ab0 to your computer and use it in GitHub Desktop.
Gerenciamento de Produtos Painel Projeto Loja Tenancy - https://codeexperts.com.br
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<x-app-layout> | |
<x-slot name="header"> | |
<h2 class="font-semibold text-xl text-gray-800 leading-tight"> | |
{{ __('Criar Produto') }} | |
</h2> | |
</x-slot> | |
<div class="py-12"> | |
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8"> | |
<div class="flex flex-col"> | |
<div class="-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8"> | |
<form action="{{route('products.store')}}" method="POST"> | |
@csrf | |
<div class="w-full mb-8"> | |
<label>Nome</label> | |
<input type="text" name="name" class="rounded w-full focus:border-gray-400 focus:ring-0"> | |
</div> | |
<div class="w-full mb-8"> | |
<label>Descrição</label> | |
<input type="text" name="description" class="rounded w-full focus:border-gray-400 focus:ring-0"> | |
</div> | |
<div class="w-full mb-8"> | |
<label>Descrição</label> | |
<textarea type="text" name="body" class="rounded w-full focus:border-gray-400 focus:ring-0"></textarea> | |
</div> | |
<div class="w-full mb-8"> | |
<label>Preço</label> | |
<input type="text" name="price" class="rounded w-full focus:border-gray-400 focus:ring-0"> | |
</div> | |
<div class="w-full mb-8"> | |
<label class="block mb-8">Categorias</label> | |
<div class="grid grid-cols-3"> | |
@forelse($categories as $category) | |
<div class="flex items-center mb-8"> | |
<input type="checkbox" name="categories[]" value="{{$category->id}}" class="rounded focus:border-gray-400 focus:ring-0 mr-2"> {{$category->name}} | |
</div> | |
@empty | |
<strong>Sem Categorias Cadastradas em sua Loja</strong> | |
@endforelse | |
</div> | |
</div> | |
<div class="w-full mb-8 border border-gray-400 rounded bg-white px-6 py-2"> | |
<label>Foto</label> | |
<input type="file" name="photo" class="rounded w-full focus:border-gray-400 focus:ring-0"> | |
</div> | |
<button class="px-4 py-2 text-xl bg-green-600 hover:bg-green-300 hover:text-green-900 border border-green-900 transition-all ease-in-out duration-200 rounded text-white font-bold"> | |
Cadastrar | |
</button> | |
</form> | |
</div> | |
</div> | |
</div> | |
</div> | |
</x-app-layout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<x-app-layout> | |
<x-slot name="header"> | |
<h2 class="font-semibold text-xl text-gray-800 leading-tight"> | |
{{ __('Editar Produto') }} | |
</h2> | |
</x-slot> | |
<div class="py-12"> | |
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8"> | |
<div class="flex flex-col"> | |
<div class="-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8"> | |
<form action="{{route('products.update', $product)}}" method="POST"> | |
@csrf | |
@method('PUT') | |
<div class="w-full mb-8"> | |
<label>Nome</label> | |
<input type="text" name="name" class="rounded w-full focus:border-gray-400 focus:ring-0" value="{{$product->name}}"> | |
</div> | |
<div class="w-full mb-8"> | |
<label>Descrição</label> | |
<input type="text" name="description" class="rounded w-full focus:border-gray-400 focus:ring-0" value="{{$product->description}}"> | |
</div> | |
<div class="w-full mb-8"> | |
<label>Descrição</label> | |
<textarea type="text" name="body" class="rounded w-full focus:border-gray-400 focus:ring-0">{{$product->body}}</textarea> | |
</div> | |
<div class="w-full mb-8"> | |
<label>Preço</label> | |
<input type="text" name="price" class="rounded w-full focus:border-gray-400 focus:ring-0" value="{{number_format($product->price, 2, ',', '.')}}"> | |
</div> | |
<div class="w-full mb-8"> | |
<label class="block mb-8">Categorias</label> | |
<div class="grid grid-cols-3"> | |
@foreach($categories as $category) | |
<div class="flex items-center mb-8"> | |
<input type="checkbox" name="categories[]" | |
@if($product->categories->contains($category)) checked @endif | |
value="{{$category->id}}" class="rounded focus:border-gray-400 focus:ring-0 mr-2"> {{$category->name}} | |
</div> | |
@endforeach | |
</div> | |
</div> | |
<div class="w-full mb-8 border border-gray-400 rounded bg-white px-6 py-2"> | |
<label>Foto</label> | |
<input type="file" name="photo" class="rounded w-full focus:border-gray-400 focus:ring-0"> | |
</div> | |
<button class="px-4 py-2 text-xl bg-green-600 hover:bg-green-300 hover:text-green-900 border border-green-900 transition-all ease-in-out duration-200 rounded text-white font-bold"> | |
Atualizar | |
</button> | |
</form> | |
</div> | |
</div> | |
</div> | |
</div> | |
</x-app-layout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<x-app-layout> | |
<x-slot name="header"> | |
<h2 class="font-semibold text-xl text-gray-800 leading-tight"> | |
{{ __('Produtos') }} | |
</h2> | |
</x-slot> | |
<div class="py-12"> | |
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8"> | |
<div class="flex justify-end mb-8"> | |
<a href="{{route('products.create')}}" class="px-6 py-2 bg-green-600 shadow text-white font-bold rounded">Criar Produto</a> | |
</div> | |
<div class="flex flex-col"> | |
<div class="-my-2 overflow-x-auto sm:-mx-6 lg:-mx-8"> | |
<div class="py-2 align-middle inline-block min-w-full"> | |
<div class="shadow overflow-hidden border-b border-gray-200 sm:rounded-lg"> | |
<table class="w-full divide-y divide-gray-200"> | |
<thead class="bg-gray-100"> | |
<tr> | |
<th scope="col" class="font-semi px-6 py-4 text-center text-xs text-gray-500 uppercase tracking-wider"> | |
# | |
</th> | |
<th scope="col" class="font-semi px-6 py-4 text-center text-xs text-gray-500 uppercase tracking-wider"> | |
Name | |
</th> | |
<th scope="col" class="px-6 py-4 text-center text-xs font-semi text-gray-500 uppercase tracking-wider"> | |
Preço | |
</th> | |
<th scope="col" class="px-6 py-4 text-center text-xs font-semi text-gray-500 uppercase tracking-wider"> | |
Criado Em | |
</th> | |
<th scope="col" class="w-48 px-6 py-4 text-center text-xs font-semi text-gray-500 uppercase tracking-wider"> | |
Ações | |
</th> | |
</tr> | |
</thead> | |
<tbody class="bg-white divide-y divide-gray-200"> | |
@forelse($products as $product) | |
<tr> | |
<td class="px-6 py-4 whitespace-nowrap text-sm text-center text-gray-500"> | |
{{$product->id}} | |
</td> | |
<td class="px-6 py-4 whitespace-nowrap text-sm text-center text-gray-500"> | |
{{$product->name}} | |
</td> | |
<td class="px-6 py-4 whitespace-nowrap text-sm text-center text-gray-500"> | |
R$ {{number_format($product->price, 2, ',', '.')}} | |
</td> | |
<td class="px-6 py-4 whitespace-nowrap text-sm text-center text-gray-500"> | |
{{$product->created_at->format('d/m/Y H:i:s')}} | |
</td> | |
<td class="w-48 px-6 py-4 whitespace-nowrap text-sm text-center text-gray-500 flex justify-between"> | |
<a href="{{route('products.edit', $product)}}" class="text-blue-500 hover:text-blue-200 font-bold hover:underline | |
transition-all ease-in-out duration-200">EDITAR</a> | |
<form action="{{route('products.destroy', $product)}}" class="destroyButton" method="POST"> | |
@csrf | |
@method("DELETE") | |
<button | |
class="text-red-500 hover:text-red-200 font-bold hover:underline transition-all ease-in-out duration-200" | |
>REMOVER</button> | |
</form> | |
</td> | |
</tr> | |
@empty | |
<tr> | |
<td colspan="5" class="px-6 py-4 whitespace-nowrap text-sm text-center text-gray-500"><h3>Nenhum produto encontrado em sua loja</h3></td> | |
</tr> | |
@endforelse | |
</tbody> | |
</table> | |
</div> | |
<div class="mt-8"> | |
{{$products->links()}} | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</x-app-layout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment