product submission
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-10">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="mb-0">Submit a Product</h3>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<form method="POST" action="{{ route('products.store') }}" enctype="multipart/form-data">
|
||||
@csrf
|
||||
|
||||
<!-- Title -->
|
||||
<div class="mb-3">
|
||||
<label for="title" class="form-label">Product Title <span class="text-danger">*</span></label>
|
||||
<input type="text"
|
||||
class="form-control @error('title') is-invalid @enderror"
|
||||
id="title"
|
||||
name="title"
|
||||
value="{{ old('title') }}"
|
||||
required
|
||||
maxlength="255"
|
||||
placeholder="e.g., My Awesome Product">
|
||||
@error('title')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@enderror
|
||||
<small class="form-text text-muted">A catchy, descriptive title for your product.</small>
|
||||
</div>
|
||||
|
||||
<!-- Description -->
|
||||
<div class="mb-3">
|
||||
<label for="description" class="form-label">Description <span class="text-danger">*</span></label>
|
||||
<textarea class="form-control @error('description') is-invalid @enderror"
|
||||
id="description"
|
||||
name="description"
|
||||
rows="5"
|
||||
required
|
||||
placeholder="Tell us about your product...">{{ old('description') }}</textarea>
|
||||
@error('description')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@enderror
|
||||
<small class="form-text text-muted">Provide a detailed description of your product (what it does, key features, etc.).</small>
|
||||
</div>
|
||||
|
||||
<!-- Website URL -->
|
||||
<div class="mb-3">
|
||||
<label for="website_url" class="form-label">Website URL <span class="text-danger">*</span></label>
|
||||
<input type="url"
|
||||
class="form-control @error('website_url') is-invalid @enderror"
|
||||
id="website_url"
|
||||
name="website_url"
|
||||
value="{{ old('website_url') }}"
|
||||
required
|
||||
placeholder="https://example.com">
|
||||
@error('website_url')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@enderror
|
||||
<small class="form-text text-muted">The full URL to your product's website or landing page.</small>
|
||||
</div>
|
||||
|
||||
<!-- Category -->
|
||||
<div class="mb-3">
|
||||
<label for="category_id" class="form-label">Category <span class="text-danger">*</span></label>
|
||||
<select class="form-select @error('category_id') is-invalid @enderror"
|
||||
id="category_id"
|
||||
name="category_id"
|
||||
required>
|
||||
<option value="">Select a category...</option>
|
||||
@foreach($categories as $category)
|
||||
<option value="{{ $category->id }}" {{ old('category_id') == $category->id ? 'selected' : '' }}>
|
||||
{{ $category->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@error('category_id')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@enderror
|
||||
<small class="form-text text-muted">Choose the category that best fits your product.</small>
|
||||
</div>
|
||||
|
||||
<!-- Thumbnail -->
|
||||
<div class="mb-3">
|
||||
<label for="thumbnail" class="form-label">Product Thumbnail</label>
|
||||
<input type="file"
|
||||
class="form-control @error('thumbnail') is-invalid @enderror"
|
||||
id="thumbnail"
|
||||
name="thumbnail"
|
||||
accept="image/*">
|
||||
@error('thumbnail')
|
||||
<span class="invalid-feedback" role="alert">
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@enderror
|
||||
<small class="form-text text-muted">Upload a product screenshot or logo (JPEG, PNG, or GIF, max 2MB).</small>
|
||||
</div>
|
||||
|
||||
<!-- Image Preview -->
|
||||
<div class="mb-3" id="imagePreview" style="display: none;">
|
||||
<label class="form-label">Preview:</label>
|
||||
<div>
|
||||
<img id="preview" src="#" alt="Thumbnail preview" style="max-width: 300px; max-height: 300px;" class="img-thumbnail">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Submit Button -->
|
||||
<div class="d-flex justify-content-between">
|
||||
<a href="{{ route('products.index') }}" class="btn btn-secondary">Cancel</a>
|
||||
<button type="submit" class="btn btn-primary">Submit Product</button>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-info mt-3" role="alert">
|
||||
<strong>Note:</strong> Your product will be reviewed by our moderators before it appears on the site.
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
document.getElementById('thumbnail').addEventListener('change', function(e) {
|
||||
const file = e.target.files[0];
|
||||
if (file) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = function(e) {
|
||||
document.getElementById('preview').src = e.target.result;
|
||||
document.getElementById('imagePreview').style.display = 'block';
|
||||
}
|
||||
reader.readAsDataURL(file);
|
||||
} else {
|
||||
document.getElementById('imagePreview').style.display = 'none';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@endsection
|
||||
Reference in New Issue
Block a user