feat: implement proposal management system including database schema, Filament resources, and client-facing preview views
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Proposal;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ProposalController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the public proposal presentation page.
|
||||
*/
|
||||
public function show(string $slug)
|
||||
{
|
||||
$proposal = Proposal::where('slug', $slug)->firstOrFail();
|
||||
|
||||
// Increment views count cleanly
|
||||
$proposal->increment('views_count');
|
||||
|
||||
return view('proposals.show', compact('proposal'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle client interaction actions (approve or revision/feedback).
|
||||
*/
|
||||
public function action(Request $request, string $slug)
|
||||
{
|
||||
$proposal = Proposal::where('slug', $slug)->firstOrFail();
|
||||
|
||||
$actionType = $request->input('action_type');
|
||||
|
||||
if ($actionType === 'approve') {
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
]);
|
||||
|
||||
$proposal->update([
|
||||
'status' => 'accepted',
|
||||
'accepted_name' => $request->input('name'),
|
||||
'accepted_at' => now(),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Teklif başarıyla onaylandı! Katılımınız ve iş birliğiniz için teşekkür ederiz.',
|
||||
]);
|
||||
}
|
||||
|
||||
if ($actionType === 'feedback') {
|
||||
$request->validate([
|
||||
'feedback' => 'required|string|max:5000',
|
||||
]);
|
||||
|
||||
$proposal->update([
|
||||
'status' => 'revised',
|
||||
'client_feedback' => $request->input('feedback'),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Revizyon ve görüşleriniz başarıyla iletildi. En kısa sürede güncellenerek sizinle paylaşılacaktır.',
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Geçersiz işlem tipi.',
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user