<?php

namespace App\Http\Controllers\Web;

use App\Http\Controllers\Controller;
use App\Page;
use App\Staff;
use Illuminate\View\View;

class StaffController extends Controller
{
    private $view = 'web.staffs.';

    /**
     * Show the application dashboard.
     * @param Staff $staff
     * @return View
     */
    public function show(Staff $staff): View
    {
        $staffPage = Page::details(6);
        $title = $staffPage->title ?? __('services.head');
        $keywords= $staffPage->keywords ??__('services.head');
        $meta_description = $staffPage->meta_description ??__('services.head');

        $staffs = Staff::withDescription($staff->id);

        $practical_experience = preg_replace('/\s\s+/', '', $staffs->practical_experience);
        $training_courses = preg_replace('/\s\s+/', '', $staffs->training_courses);
        $skills = preg_replace('/\s\s+/', '', $staffs->skills);

        $practical_experience = explode('@@', $practical_experience); //'<p>@@</p>
        $training_courses = explode('@@', $training_courses);
        $skills = explode('@@', $skills);




//        $practical_experience = $staffs->practical_experience;
//        $scientific_expertise = $staffs->scientific_expertise;

//        preg_match_all('/<h6>[\p{Arabic}a-zA-z0-9_,.~\-!@#\$%\^&*\(\)\s]+<\/h6>/m', $practical_experience, $peHeading);
//        preg_match_all('/<p>[\p{Arabic}a-zA-Z0-9,.~\-!@#\$%\^&*\(\)\s]+<\/p>/m', $practical_experience, $peParagraph);

//        preg_match_all('/<p>[\p{Arabic}a-zA-Z0-9,.~\-!@#\$%\^&*\(\)\s]+<\/p>/m', $scientific_expertise, $seParagraph);
//        preg_match_all('/<h6>[\p{Arabic}a-zA-z0-9_,.~\-!@#\$%\^&*\(\)\s]+<\/h6>/m', $scientific_expertise, $seHeading);


//        preg_match_all('/<h6>[\p{Arabic}a-zA-z0-9_,.~\-!@#\$%\^&*\(\)\s\W]+<\/p>/m', $practical_experience, $practical_experience_matches);
//
//        preg_match_all('/<h6>[\p{Arabic}a-zA-z0-9_,.~\-!@#\$%\^&*\(\)\s\W]+<\/p>/m', $scientific_expertise, $scientific_expertise_matches);

//        dd($practical_experience_matches, $scientific_expertise_matches);
//        dd($peHeading, $peParagraph, $seHeading, $seParagraph);
//        $practical_experience = array_first(array_first($practical_experience_matches));
//        $scientific_expertise = array_first(array_first($scientific_expertise_matches));

//        foreach ($peHeading as $item) {
//            $practical_experience['heading'] = $item;
//            $practical_experience['paragraph'] = array_first($peParagraph);
//        }
//
//
//        foreach ($seHeading as $item) {
//            $scientific_expertise['heading'] = $item;
//            $scientific_expertise['paragraph'] = array_first($seParagraph);
//        }

//        dd($practical_experience, $scientific_expertise);

        return view($this->view.'show', compact('staffs', 'staffPage', 'title', 'keywords', 'meta_description', 'practical_experience', 'training_courses', 'skills'));
    }
}
