<?php

namespace App\Http\Controllers\Web;

use App\Http\Controllers\Controller;
use App\Models\Category;
use App\Models\EmploymentApplication;
use App\Models\ManufacturingRequest;
use App\Models\Post;
use App\Models\Service;
use App\Models\ServiceOrder;
use Illuminate\Http\Request;

class EmploymentApplicationController extends Controller
{

    public function index()
    {

        $title = awtTrans('انضم إلينا');

        return view('web.employment-applications.index', compact('title'));
    }

    public function show($slug)
    {

        $title = 'Services';

        $service = Service::findBySlugOrFail($slug);
        $title_model = $service->name_en;

        return view('web.services.show', compact('service', 'title', 'title_model'));
    }

    // store
    public function store(Request $request)
    {

        $data = $request->except('cv');
        $fileName = time() . '_' . $request->cv->getClientOriginalName();
        $data['cv'] = $request->file('cv')->storeAs('cv', $fileName, 'public');

        EmploymentApplication::create($data);

        return redirect()->back()->with('success', awtTrans('تم ارسال الطلب بنجاح'));
    }
}
