mirror of
https://github.com/openclassify/openclassify.git
synced 2026-04-14 11:12:09 -05:00
- Complete rewrite using Laravel 12 framework - Modular architecture with nwidart/laravel-modules v11 - Modules: Category, Listing, Location, Profile - 8 top-level categories with 33 subcategories seeded - 6 sample listings seeded - 5 countries, 13 cities, districts seeded - Multi-language support: en, tr, ar, zh, es, fr, de, pt, ru, ja - Auth scaffolding via Laravel Breeze - Partner dashboard for user listing management - Tailwind CSS via CDN for styling - SQLite database for development - RTL support for Arabic locale Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
namespace Modules\Listing\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
use Modules\Listing\Models\Listing;
|
|
|
|
class ListingController extends Controller
|
|
{
|
|
public function index(Request $request)
|
|
{
|
|
$listings = Listing::where('status', 'active')
|
|
->orderByDesc('is_featured')
|
|
->orderByDesc('created_at')
|
|
->paginate(12);
|
|
return view('listing::index', compact('listings'));
|
|
}
|
|
|
|
public function show(Listing $listing)
|
|
{
|
|
return view('listing::show', compact('listing'));
|
|
}
|
|
|
|
public function create()
|
|
{
|
|
return view('listing::create');
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
$data = $request->validate([
|
|
'title' => 'required|string|max:255',
|
|
'description' => 'nullable|string',
|
|
'price' => 'nullable|numeric',
|
|
'category_id' => 'nullable|integer',
|
|
'contact_email' => 'nullable|email',
|
|
'contact_phone' => 'nullable|string',
|
|
]);
|
|
$data['user_id'] = auth()->id();
|
|
$data['slug'] = \Illuminate\Support\Str::slug($data['title']) . '-' . \Illuminate\Support\Str::random(6);
|
|
$listing = Listing::create($data);
|
|
return redirect()->route('listings.show', $listing)->with('success', 'Listing created!');
|
|
}
|
|
}
|