<?php


namespace App\Controllers;

use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\API\ResponseTrait;

class Myfit extends BaseController
{
    use ResponseTrait;
    protected $request;

    public function __construct()
    {
        $this->request = $request = \Config\Services::request();
    }


    public function index()
    {
        $mBlogData = new \App\Models\myfitBlogData();
        $res1 = $mBlogData->getBlogData([]);
        return $this->response->setJson($res1);
    }

    public function pricing()
    {
        $mBlogData = new \App\Models\myfitBlogData();
        $res1 = $mBlogData->getBlogData([]);
        return $this->response->setJson($res1);
    }

    public function contact()
    {
          $inx = array(
        'name' => $this->post('name'),
        'email' => $this->post('email'),
        'country' => $this->post('country'),
        'phone' => $this->post('phone'),
        'message' => $this->post('message')
        );
        $something = $this->request->getVar('name');
        $raw_json = file_get_contents("php://input");
        $raw_array = json_decode($raw_json, true);

        $inx = ['olu' => rand(100, 8888). $something];
        $mBlogData = new \App\Models\myfitBlogData();
        $res1 = $mBlogData->getBlogData([]);
        //return $this->response->setJson($res1);
        return $this->response->setJson($inx);
    }


    public function blogdata()
    {
        $mBlogData = new \App\Models\myfitBlogData();
        $res1 = $mBlogData->getBlogData([]);
        return $this->response->setJson($res1);
    }

    public function country()
    {
        $mCountry = new \App\Models\myfitCountry();
        return $this->response->setJson($mCountry->getSiteCountries([]));
    }

}