Issues (185)

app/Http/Controllers/ApplyController.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Events\CandidateApplied;
6
use App\Http\Requests\CandidatesCreateRequest;
7
use App\Http\Resources\ApplyFormResource;
8
use App\Jobs\ProcessResume;
9
use App\Models\Source;
10
use App\Services\TenantManager;
11
use App\Utils\Candidates\CandidateCreator;
12
13
class ApplyController extends Controller
14
{
15
    /**
16
     * @var TenantManager
17
     */
18
    protected $tenantManager;
19
20
    /**
21
     * Create a new controller instance.
22
     *
23
     * @param TenantManager $tenantManager
24
     *
25
     * @return void
26
     */
27
    public function __construct(TenantManager $tenantManager)
28
    {
29
        $this->tenantManager = $tenantManager;
30
    }
31
32
    public function applyForm($sourceKey)
33
    {
34
        $source = Source::where('key', $sourceKey)->with('recruitment.formFields')->get()->first();
35
36
        if (empty($source)) {
37
            return response()->json(['message' => 'Recruitment not found'], 404);
38
        }
39
40
        return new ApplyFormResource($source->recruitment);
41
    }
42
43
    public function apply(CandidatesCreateRequest $request)
44
    {
45
        $source = Source::where('key', $request->get('key'))->get()->first();
0 ignored issues
show
The method get() does not exist on App\Http\Requests\CandidatesCreateRequest. ( Ignorable by Annotation )

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

45
        $source = Source::where('key', $request->/** @scrutinizer ignore-call */ get('key'))->get()->first();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
46
        if (empty($source)) {
47
            return response()->json(['message' => 'Recruitment not found'], 404);
48
        }
49
50
        $candidate = CandidateCreator::createCandidate($request, $this->tenantManager);
51
52
        ProcessResume::dispatch($candidate);
53
        event(new CandidateApplied($candidate));
54
55
        return response()->json($candidate, 201);
56
    }
57
}
58