where('is_active', true) ->orderBy('sort_order') ->orderBy('created_at', 'desc') ->get() ->map(fn ($form) => [ 'id' => $form->id, 'title' => $form->title, 'description' => $form->description, 'file_url' => $form->file_url, 'file_type' => strtoupper(pathinfo($form->file_path, PATHINFO_EXTENSION)), 'direction' => $form->direction, ]); return response()->json([ 'success' => true, 'data' => $forms, ]); } /** * دریافت تعهدنامه‌ها بر اساس جهت ارسال * GET /api/v1/commitment-forms/{direction} */ public function byDirection(string $direction): JsonResponse { $forms = CommitmentForm::query() ->where('is_active', true) ->where(function ($query) use ($direction) { $query->where('direction', 'both') ->orWhere('direction', $direction); }) ->orderBy('sort_order') ->orderBy('created_at', 'desc') ->get() ->map(fn ($form) => [ 'id' => $form->id, 'title' => $form->title, 'description' => $form->description, 'file_url' => $form->file_url, 'file_type' => strtoupper(pathinfo($form->file_path, PATHINFO_EXTENSION)), 'direction' => $form->direction, ]); return response()->json([ 'success' => true, 'data' => $forms, ]); } }