<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| 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([
    'middleware' => 'api',
    'namespace' => 'Auth',
    'prefix' => 'auth',
], function () {
    Route::post('login', 'AuthController@login');
    Route::post('logout', 'AuthController@logout');
    Route::get('refresh', 'AuthController@refresh');
    Route::get('user', 'AuthController@user');
    Route::post('register', 'RegisterController@register');

    Route::post('{provider}/callback', 'SocialAuthController@handleProviderCallback');
});

Route::group(['namespace' => 'Resources',], function () {
  Route::get('/users/template', 'UserController@template')->name('users.template');
  Route::get('/users/export', 'UserController@export')->name('users.export');
});

Route::group(['middleware' => ['jwt.auth'],], function () {
    Route::get('vue', 'IndexController@vue');
    Route::get('dashboard', 'IndexController@dashboard');
    Route::group(['namespace' => 'Resources',], function () {
        Route::delete('/users/{id}/notifications', 'UserController@readAll')->name('users.readAll');
        Route::delete('/users/{id}/notifications/{notifiation}', 'UserController@read')->name('users.read');
        Route::put('/users/{id}/actived', 'UserController@actived')->name('users.actived');
        Route::put('/users/{id}/inactived', 'UserController@inactived')->name('users.inactived');
        Route::delete('/users/delete', 'UserController@destroyMany')->name('users.destroyMany');
        Route::apiResource('users', 'UserController');
        Route::apiResource('pages', 'PageController');
        Route::apiResource('posts', 'PostController');
    });
});
