- GET/POST /api/contracts/reports y /api/postulations/reports
- GET/POST /api/contracts/reports/{id}/comments con verificación de autoría
- Fix distancia withinDistanceTo: 0.5 grados → 5000 metros (SRID 4326)
- Fix FK Report::finishedcontracts() → contract_id
- Wrap todas las llamadas OneSignal en try/catch para evitar crashes
- Chat UI de comentarios: burbujas por rol, botón veredicto fijo, estilos
- Botón veredicto movido de reports/index a reports/comments
- Ruta POST veredict y restructura reports/{id}/comments en web
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
53 lines
1.5 KiB
PHP
Executable File
53 lines
1.5 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Report;
|
|
use App\Models\ReportComment;
|
|
use App\Models\FinishedContracts;
|
|
use App\Models\NoHome;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
|
class ReportCommentController extends Controller
|
|
{
|
|
public function index(Request $request, $id)
|
|
{
|
|
$report = Report::find($id);
|
|
$contract = FinishedContracts::with(['user', 'suppliers.user', 'categories'])->find($report->contract_id);
|
|
$nohome = NoHome::where('contract_id', $contract->id)->first();
|
|
$comments = ReportComment::with('user')
|
|
->where('report_id', $id)
|
|
->orderBy('created_at', 'asc')
|
|
->paginate(50);
|
|
|
|
return view('reports.comments', compact('comments', 'contract', 'nohome', 'report'));
|
|
}
|
|
|
|
public function store(Request $request, $id)
|
|
{
|
|
$validator = Validator::make($request->all(), [
|
|
'comment' => 'required|string',
|
|
]);
|
|
|
|
if ($validator->fails()) {
|
|
return redirect()->back()->withErrors($validator);
|
|
}
|
|
|
|
$comment = new ReportComment();
|
|
$comment->report_id = $id;
|
|
$comment->user_id = Auth::id();
|
|
$comment->comment = strip_tags($request->comment);
|
|
$comment->save();
|
|
|
|
return redirect()->back();
|
|
}
|
|
|
|
public function destroy($id, $comment_id)
|
|
{
|
|
ReportComment::destroy($comment_id);
|
|
return redirect('reports/' . $id . '/comments');
|
|
}
|
|
}
|