academico-sis /
academico
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Http\Controllers; |
||
| 4 | |||
| 5 | use App\Events\LeadStatusUpdatedEvent; |
||
| 6 | use App\Models\Student; |
||
| 7 | use Illuminate\Http\Request; |
||
| 8 | |||
| 9 | class LeadStatusController extends Controller |
||
| 10 | { |
||
| 11 | public function update(Request $request) |
||
| 12 | { |
||
| 13 | $listId = null; |
||
|
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
| 14 | // create or update the lead status record for the selected student |
||
| 15 | $student = Student::findOrFail($request->input('student')); |
||
| 16 | $student->lead_type_id = $request->input('status'); |
||
| 17 | $student->save(); |
||
| 18 | |||
| 19 | // if the sync with external mailing system is enabled |
||
| 20 | if (config('mailing-system.external_mailing_enabled') == true) { |
||
| 21 | match ($request->input('status')) { |
||
| 22 | 1 => $listId = config('mailing-system.mailerlite.activeStudentsListId'), |
||
| 23 | 2, 3 => $listId = config('mailing-system.mailerlite.inactiveStudentsListId'), |
||
| 24 | default => abort(422, 'List ID not found'), |
||
| 25 | }; |
||
| 26 | |||
| 27 | LeadStatusUpdatedEvent::dispatch($student, $listId); |
||
| 28 | |||
| 29 | foreach ($student->contacts as $contact) { |
||
| 30 | LeadStatusUpdatedEvent::dispatch($contact, $listId); |
||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | return $student->lead_type_id; |
||
| 35 | } |
||
| 36 | } |
||
| 37 |