Fixed api issue
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Models\BylawNode;
|
||||
use App\Models\BylawCodificationLink;
|
||||
use App\Traits\BaseApiResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class BylawApiController extends Controller
|
||||
{
|
||||
@@ -309,13 +310,18 @@ class BylawApiController extends Controller
|
||||
|
||||
$description = $item->description;
|
||||
|
||||
// Direct Query Fallback: If description is empty, fetch node_content manually
|
||||
if (empty($description)) {
|
||||
$description = BylawNode::where('document_id', $item->id)
|
||||
// Check if description is practically empty (null, empty string, or just empty WYSIWYG HTML like <p></p>)
|
||||
$cleanDesc = trim(strip_tags($description ?? ''));
|
||||
|
||||
// Direct Query Fallback: Fetch node_content manually via DB facade to bypass any Model restrictions
|
||||
if (empty($cleanDesc)) {
|
||||
$nodeContents = DB::table('bylaw_nodes')
|
||||
->where('document_id', $item->id)
|
||||
->orderBy('sort_order', 'asc')
|
||||
->pluck('node_content')
|
||||
->filter()
|
||||
->implode("\n\n");
|
||||
->toArray();
|
||||
|
||||
$description = implode("\n\n", array_filter($nodeContents));
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user