<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

// Route::get('/', function () {
//     return view('welcome');
// });
Route::get('/', 'App\Http\Controllers\PageController@welcome')->name('welcome');
Route::get('/visiMisi', 'App\Http\Controllers\PageController@visiMisi')->name('visiMisi');

Route::get('/news/view/{code}', 'App\Http\Controllers\BeritaController@show')->name('news.view');
Route::get('/docs/view', 'App\Http\Controllers\JenisDokumenController@show')->name('docs.view');
Route::get('/docs/get/{code}', 'App\Http\Controllers\DokumensController@get_by_jenis')->name('docs.get');

// Auth::routes();

// Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
Auth::routes();



Route::group(['middleware' => 'auth'], function () {
	
	Route::get('/home', 'App\Http\Controllers\HomeController@index')->name('dashboard');
	Route::resource('user', 'App\Http\Controllers\UserController', ['except' => ['show']]);
	Route::get('profile', ['as' => 'profile.edit', 'uses' => 'App\Http\Controllers\ProfileController@edit']);
	Route::patch('profile', ['as' => 'profile.update', 'uses' => 'App\Http\Controllers\ProfileController@update']);
	Route::patch('profile/password', ['as' => 'profile.password', 'uses' => 'App\Http\Controllers\ProfileController@password']);

	Route::get('/docs/download/{code}', 'App\Http\Controllers\DokumensController@getDownload')->name('docs.download');

	// JENIS DOKUMEN
	Route::get('/jenis_doc', 'App\Http\Controllers\JenisDokumenController@index')->name('jenis.doc');
	Route::get('/jenis_doc/all', 'App\Http\Controllers\JenisDokumenController@getAll')->name('jenis.all');
	Route::post('/jenis_doc/save', 'App\Http\Controllers\JenisDokumenController@store')->name('jenis.save');
	Route::post('/jenis_doc/update', 'App\Http\Controllers\JenisDokumenController@update')->name('jenis.update');
	Route::post('/jenis_doc/child', 'App\Http\Controllers\JenisDokumenController@addChild')->name('jenis.child');
	Route::get('/jenis_doc/table', 'App\Http\Controllers\JenisDokumenController@getDatatables')->name('jenis.table');
	Route::get('/jenis_doc/get/{code}', 'App\Http\Controllers\JenisDokumenController@get_by_id')->name('jenis.get');
	Route::get('/jenis_doc/delete/{code}', 'App\Http\Controllers\JenisDokumenController@delete')->name('jenis.delete');
	// Route::resource('jenis_doc', 'App\Http\Controllers\JenisDokumenController');

	// DOKUMEN
	Route::get('/doc', 'App\Http\Controllers\DokumensController@index')->name('doc.index');
	Route::get('/doc/download/{code}', 'App\Http\Controllers\DokumensController@getDownload')->name('doc.download');
	Route::get('/doc/add', 'App\Http\Controllers\DokumensController@add')->name('doc.add');
	Route::get('/doc/json', 'App\Http\Controllers\DokumensController@getDatatables')->name('doc.json');
	Route::post('/doc/save', 'App\Http\Controllers\DokumensController@store')->name('doc.save');
	Route::get('/doc/delete/{code}', 'App\Http\Controllers\DokumensController@delete')->name('doc.delete');
	Route::get('/doc/show/{code}', 'App\Http\Controllers\DokumensController@showData')->name('doc.show');
	Route::post('/doc/update', 'App\Http\Controllers\DokumensController@update')->name('doc.update');

	// BERITA
	Route::get('/news', 'App\Http\Controllers\BeritaController@index')->name('news.index');
	Route::get('/news/json', 'App\Http\Controllers\BeritaController@getDatatables')->name('news.json');
	Route::get('/news/add', 'App\Http\Controllers\BeritaController@add')->name('news.add');
	Route::post('/news/save', 'App\Http\Controllers\BeritaController@store')->name('news.save');
	Route::get('/news/show/{code}', 'App\Http\Controllers\BeritaController@showData')->name('news.show');
	Route::post('/news/update', 'App\Http\Controllers\BeritaController@update')->name('news.update');
	Route::get('/news/delete/{code}', 'App\Http\Controllers\BeritaController@delete')->name('news.delete');

	// USER
	Route::get('/user', 'App\Http\Controllers\UserController@index')->name('user.index');
	Route::post('/user/save', 'App\Http\Controllers\UserController@store')->name('user.save');
	Route::post('/user/update', 'App\Http\Controllers\UserController@update')->name('user.update');
	Route::post('/user/status', 'App\Http\Controllers\UserController@change_status')->name('user.status');
	Route::get('/user/json', 'App\Http\Controllers\UserController@getDatatables')->name('user.json');
	Route::get('/user/get/{code}', 'App\Http\Controllers\UserController@get_by_id')->name('user.get');
	Route::get('/user/delete/{code}', 'App\Http\Controllers\UserController@delete')->name('user.delete');
});

Route::group(['middleware' => 'auth'], function () {
	Route::get('{page}', ['as' => 'page.index', 'uses' => 'App\Http\Controllers\PageController@index']);
});

