pai-sklep/resources/views/product/edit.blade.php

36 lines
1.2 KiB
PHP

@extends('layouts.app')
@section('title', "Sklep")
@section('main')
@if($new)
@php($post_url = route("product.store"))
@else
@php($post_url = route("product.update", $product))
@endif
<form action="{{ $post_url }}" method="post" enctype="multipart/form-data">
<input type="text" name="name" value="{{ $product->name }}">
<textarea name="description">{{ $product->description }}</textarea>
<input type="number" name="price" value="{{ $product->price }}">
<input type="file" name="image">
@foreach($categories as $category)
<input type="checkbox" id="category_{{$loop->index}}" name="category[{{$loop->index}}]" value="{{$category->uuid}}" @if($category->products()->find($product)) checked @endif>
<label for="category_{{$loop->index}}">{{$category->name}}</label>
@endforeach
<button type="submit">Zatwierdź</button>
@if(!$new)
@method("PATCH")
@endif
@csrf
</form>
@foreach($product->images as $vis)
<form action="{{ route("image.destroy", $vis) }}" method="post">
<img src="{{ $vis->URL() }}"/>
<button type="submit">Usuń</button>
@method("DELETE")
@csrf
</form>
@endforeach()
@endsection()