<?php

use Illuminate\Http\Request;
use App\Models\Categories;
use Carbon\Carbon;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::group([
    'prefix' => 'auth'
], function () {
    Route::post('login', 'Auth\AuthController@login')->name('login');
    Route::post('register', 'Auth\AuthController@register');
    Route::post('fb', 'Auth\AuthController@fb')->name('fb');
    Route::post('google', 'Auth\AuthController@google')->name('google');
    //Route::post('apple', 'Auth\AuthController@apple')->name('apple');
    Route::post('forgot/password', 'Auth\ForgotPasswordController@sendResetLinkEmail');

    Route::group([
      'middleware' => 'auth:api'
    ], function() {
        Route::get('logout', 'Auth\AuthController@logout');
        Route::get('user', 'Auth\AuthController@user');
        Route::post('verify', 'Auth\AuthController@verify')->name('verify');
    });
});

Route::group([
  'prefix' => 'payments',
  'middleware' => 'auth:api'
], function() {
    Route::post('addcard', 'PaymentController@addcard');
    Route::post('deletecard', 'PaymentController@deletecard');
    Route::get('getcards', 'PaymentController@getcards');
});

Route::group([
  'prefix' => 'contracts',
  'middleware' => 'auth:api'
], function() {
    Route::post('create', 'ContractController@create');
    Route::post('coupon', 'ContractController@coupon');
    Route::post('coupon-extra', 'ContractController@couponextra');
    Route::get('pending', 'PostulationController@getpendingcontracts');
    Route::get('current', 'ContractController@getcurrentcontracts');
    Route::get('finished', 'ContractController@getfinishedcontracts');
    Route::post('cancel', 'ContractController@cancelcontract');
    Route::post('start', 'ContractController@startcontract');
    Route::post('review', 'ContractController@reviewcontract');
    Route::post('extra', 'ContractController@extra');
    Route::post('report', 'ReportController@report');
    Route::get('nohome-check', 'NoHomeController@nohomecheck');
    Route::post('nohome-confirm', 'NoHomeController@nohomeconfirm');
    //Route::post('nohome-test', 'NoHomeController@test');
    //Route::get('redated', 'PostulationController@deletecard');
    //Route::get('current', 'PostulationController@getcards');
    //Route::get('finished', 'PostulationController@getcards');
});

Route::group([
  'middleware' => 'auth:api'
], function() {
    Route::post('add-hero', 'SupplierController@hero');
    Route::post('create-postulation', 'PostulationController@create');
    Route::get('check-category', 'SupplierController@check');
    Route::get('get-postulations', 'SupplierController@getpostulation');
    Route::get('get-contracted-postulations', 'SupplierController@getcontractedpostulation');
    Route::get('get-finished-postulations', 'PostulationController@getfinishedpostulations');
    Route::get('get-postulants', 'PostulationController@getpostulants');
    Route::post('postulate', 'PostulationController@postulate');
});

Route::get('/parameters', 'IChambaParameterController@parameters');


Route::get('/en-categories-name', function () {
    $categories=Categories::all()->pluck('en_name')->toArray();
    return response()->json($categories);
});

Route::get('/categories-name', function () {
    $categories=Categories::all()->pluck('name')->toArray();
    return response()->json($categories);
});
