<?php

namespace App\Http\Controllers\Web;

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

class ServiceController extends Controller
{

    public function index()
    {

        $title = 'Services';

        $services = Service::where('parent_id' , null)->orderBy('id', 'desc')->paginate(12);
        return view('web.services.index', compact('services', 'title'));
    }

    public function show($slug)
    {


        $service = Service::findBySlugOrFail($slug);
        $questions = Question::all();
        $title = $service->name;
        $photo = $service->photo;
        $title_model = $service->name_en;

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

    // store
    public function store(Request $request)
    {
        ServiceOrder::create($request->all());

        return redirect()->back()->with('success', 'Order Successfully');
    }
}
