<?php

namespace App\Http\Controllers;

use App\Models\FirmType;
use Illuminate\Auth\Events\Verified;
use Illuminate\Http\Request;

class FirmTypeController extends Controller
{
    /**
     * Display a listing of the resource.
     */
    public function index()
    {
        return FirmType::all();
    }


    public function store(Request $request)
    {
        FirmType::create([...$this->validateFirmTypeRequest($request),
            'verified' => false,
        ]);

        return back(303)->with(['success' => 'success']);
    }

    public function validateFirmTypeRequest(Request $request)
    {
        return $request->validate([
            'name_en' => 'required',
            'name_ar' => 'required',
        ]);
    }

    public function update(Request $request, FirmType $firmType)
    {

        $firmType->update($this->validateSkillRequest($request));

        return back(303)->with(['success' => 'success']);
    }

    public function destroy(FirmType $firmType)
    {
        $firmType->delete();
        return back(303)->with(['success' => 'success']);
    }
}
