Complete grouped collaborative editorial queues and native review coverage
tests / ci (push) Waiting to run
tests / ci (push) Waiting to run
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\InvestmentZone;
|
||||
use App\Services\PortalEditorialSubjects;
|
||||
use App\Services\PortalEditorialWorkflow;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -36,14 +38,28 @@ class InvestmentZoneRelationController extends Controller
|
||||
DB::table('investment_zone_relations')->insert([...$data, 'id' => $relation, 'zone_id' => $id,
|
||||
'editor_id' => $request->user()->id, 'created_at' => now(), 'updated_at' => now()]);
|
||||
$this->audit($relation, $request->user()->id, 'created', 1);
|
||||
if (app(PortalEditorialSubjects::class)->available()) {
|
||||
app(PortalEditorialWorkflow::class)->saveSubject($request->user(), 'zone-relations', $relation, 0, [...$data, 'zone_id' => $id], true);
|
||||
}
|
||||
|
||||
return response()->json(DB::table('investment_zone_relations')->where('id', $relation)->first(), 201);
|
||||
$record = DB::table('investment_zone_relations')->where('id', $relation)->first();
|
||||
if (app(PortalEditorialSubjects::class)->available()) {
|
||||
$record->editorial_url = '/management/editorial/subjects/zone-relations/'.$relation;
|
||||
$record->pending_publication = true;
|
||||
}
|
||||
|
||||
return response()->json($record, 201);
|
||||
});
|
||||
}
|
||||
|
||||
public function review(Request $request, string $id, string $action): JsonResponse
|
||||
{
|
||||
$data = $request->validate(['version_no' => ['required', 'integer', 'min:1']]);
|
||||
if (app(PortalEditorialSubjects::class)->writes('zone-relations', $id)) {
|
||||
app(PortalEditorialSubjects::class)->authorize($request->user(), 'zone-relations', $id, true);
|
||||
|
||||
return response()->json(['pending_publication' => true, 'editorial_url' => '/management/editorial/subjects/zone-relations/'.$id]);
|
||||
}
|
||||
|
||||
return DB::transaction(function () use ($request, $id, $action, $data) {
|
||||
$relation = DB::table('investment_zone_relations')->where('id', $id)->lockForUpdate()->first();
|
||||
|
||||
Reference in New Issue
Block a user