Issues (404)

Branch: dev

Http/Controllers/ApplicationReviewController.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Models\ApplicationReview;
6
use App\Models\JobApplication;
7
use App\Models\Lookup\ReviewStatus;
8
use Illuminate\Http\Request;
9
use Illuminate\Validation\Rule;
10
11
class ApplicationReviewController extends Controller
12
{
13
    /**
14
     * Update the review for the specified application.
15
     *
16
     * @param  \Illuminate\Http\Request   $request     Incoming Request.
17
     * @param  \App\Models\JobApplication $application Incoming Application.
18
     * @return \Illuminate\Http\Response
19
     */
20
    public function updateForApplication(Request $request, JobApplication $application)
21
    {
22
        $request->validate([
23
            'review_status_id' => [
24
                'nullable',
25
                Rule::in(ReviewStatus::all()->pluck('id')->toArray())
26
            ],
27
            'notes' => 'nullable|string'
28
        ]);
29
30
        $review = $application->application_review;
31
        if ($review === null) {
32
            $review = new ApplicationReview();
33
            $review->job_application()->associate($application);
34
        }
35
        $review->fill([
36
            'review_status_id' => $request->input('review_status_id'),
37
            'notes' => $request->input('notes'),
38
        ]);
39
        $review->save();
40
41
        if ($request->ajax()) {
42
            return $review->fresh()->toJson();
43
        }
44
45
        return redirect()->back();
0 ignored issues
show
The function redirect was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

45
        return /** @scrutinizer ignore-call */ redirect()->back();
Loading history...
46
    }
47
}
48