<?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\Storage;
use Illuminate\Http\Request;
use App\Http\Requests\add_apply_request;
use App\Models\Job;
use App\Models\Apply;
use Illuminate\Support\Facades\Auth;

class ApplyController extends Controller
{
    
    public function applys($job)
    {
        // $job = Job::with('user')->find($job);
        // $job = Job::where('user_id', $job)->with(['user'])->get();
        $apply = Apply::where('job_id', $job)->get();

        return view('applys', ['apply' => $apply]);    
    }

    public function addapply(Job $job, add_apply_request $request)
    {
        $ap = new Apply();
        $ap->user_id = Auth::id();
        $ap->job_id = $job->id;
        $ap->website = $request->website;
        $ap->resume = $request->resume;
        $ap->save();

        return redirect()->route('index');
    }
}
