<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

use App\Models\doctors;

class doctorsController extends Controller
{
    public function addDoctor(Request $req)
    {
        $data = [
            'name' => $req->name,
            'email' => $req->email,
            'phone' => $req->phone,
            'area_of_practice' => $req->area_of_practice,
            'province' => $req->province,
            'address' => $req->address,
            'area' => $req->area,
            'language' => 'English'
        ];

        doctors::create($data);

        return ['message' => 'Doctor was added'];
    }

    public function getDoctor()
    {
        return doctors::all();
    }

    public function editDoctors(Request $req, $id)
    {
        $Dr = doctors::find($id);

        $data = [
            'name' => $req->name,
            'email' => $req->email,
            'phone' => $req->phone,
            'area_of_practice' => $req->area_of_practice,
            'province' => $req->province,
            'area' => $req->area,
            'address' => $req->address,
            'language' => $req->language
        ];

        $Dr->update($data);

        return ['message' => 'Doctor was updated'];
    }
}
