我是laravel的新手。我想知道如何在最佳實踐中編寫Laravel 5路線。Laravel 5路線最佳實踐?
這是我的路線到目前爲止。
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
/* start contoh acl simple
Route::get('owner', ['middleware' => 'role:owner', function() {
return 'cie owner masuk :p';
}]);
Route::get('manager', ['middleware' => 'role:manager', function() {
return 'halo pak manager';
}]);
Route::get('denied/{role}', function ($role) {
if($role){
return 'hayo ngapain akses halaman '.$role.', emang kamu siapa? kan cuma client :p cie dah paham middleware nieh';
}
return 'boleh lah akses sini';
});
end contoh acl simple */
// use Illuminate\Support\Facades\App;
// use LaravelPusher;
// Route::auth();
Route::get('/jembatan', function(){
// $message = 'mantap coyyy';
// $pusherx = App::make('pusher');
// LaravelPusher::trigger('my-channel', 'my-event', ['message' => $message]);
$messages = [
"id" => 5,
"jenis" => 'afdsa',
"no_kendaraan" => 'L 1334 H',
"status" => 'Menunggu',
];
LaravelPusher::trigger('antrian', 'newAntrian', $messages);
return 'success';
});
Route::get('/', 'Auth\[email protected]');
Route::post('/', 'Auth\[email protected]');
///*
Route::get('/register', 'Auth\[email protected]');
Route::post('/register', 'Auth\[email protected]');
Route::get('/password/reset/{token?}', 'Auth\[email protected]');
Route::post('/password/reset', 'Auth\[email protected]');
Route::post('/password/email', 'Auth\[email protected]');
Route::get('/logout', 'Auth\[email protected]');
//*/
Route::get('/home', '[email protected]')->name('home');
//route inti
Route::get('layarAntrian/{id}', '[email protected]')->name('guest.layarAntrian');
//owner
Route::group(['prefix' => 'owner', 'middleware' => ['auth', 'role:owner']], function() {
//input showrooms baru >> assign manager (detail n salary)
Route::get('showrooms', '[email protected]')->name('owner.showrooms');
Route::get('showrooms/create', '[email protected]')->name('owner.showrooms.create');
Route::post('showrooms/create', '[email protected]')->name('owner.showrooms.store');
Route::get('showrooms/{id}/show', '[email protected]')->name('owner.showrooms.show');
Route::get('showrooms/{id}/delete', '[email protected]')->name('owner.showrooms.destroy');
Route::get('showrooms/{id}/edit', '[email protected]')->name('owner.showrooms.edit');
Route::patch('showrooms/{id}/update', '[email protected]');
//input manager baru
// /managers
Route::get('managers', '[email protected]')->name('owner.managers.index');
Route::get('managers/{id}/show', '[email protected]')->name('owner.managers.show');
Route::get('managers/create', '[email protected]')->name('owner.managers.create');
/*
Route::get('managers/create', function(){
return 'x bro';
});
*/
Route::post('managers/create', '[email protected]')->name('owner.managers.store');
Route::get('managers/{id}/delete', '[email protected]')->name('owner.managers.destroy');
Route::get('managers/{id}/edit', '[email protected]')->name('owner.managers.edit');
Route::patch('managers/{id}/update', '[email protected]')->name('owner.managers.update');
});
//manager
Route::group(['middleware' => ['auth', 'role:manager']], function() {
//laporan keuangan, stock, aset
//input accountant, operator, cleaner
Route::get('employees', '[email protected]')->name('manager.employees.index');
Route::get('employees/{id}/show', '[email protected]')->name('manager.employees.show');
Route::get('employees/create', '[email protected]')->name('manager.employees.create');
Route::post('employees/store', '[email protected]')->name('manager.employees.store');
Route::get('employees/{id}/edit', '[email protected]')->name('manager.employees.edit');
Route::patch('employees/{id}/update', '[email protected]')->name('manager.employees.update');
Route::get('employees/{id}/delete', '[email protected]')->name('manager.employees.destroy');
//aturan tarif, gaji, insentif
// /pricings /pricings/create /pricings/{id} /pricings/{id}/edit
Route::get('pricings', '[email protected]')->name('manager.pricings.index');
Route::get('pricings/{id}/show', '[email protected]')->name('manager.pricings.show');
Route::get('pricings/create', '[email protected]')->name('manager.pricings.create');
Route::post('pricings/store', '[email protected]')->name('manager.pricings.store');
Route::get('pricings/{id}/edit', '[email protected]')->name('manager.pricings.edit');
Route::patch('pricings/{id}/update', '[email protected]')->name('manager.pricings.update');
Route::get('pricings/{id}/delete', '[email protected]')->name('manager.pricings.destroy');
// /salaries /salaries/create /salaries/{id} /salaries/{id}/edit
// /bonuses /bonuses/create /bonuses/{id} /bonuses/{id}/edit
// pindahan dari operator
Route::get('materials', '[email protected]')->name('manager.materials.index');
Route::get('materials/{id}/show', '[email protected]')->name('manager.materials.show');
Route::get('materials/create', '[email protected]')->name('manager.materials.create');
Route::post('materials/store', '[email protected]')->name('manager.materials.store');
Route::get('materials/{id}/edit', '[email protected]')->name('manager.materials.edit');
Route::get('materials/{id}/stock', '[email protected]')->name('manager.materials.stock');
Route::post('materials/{id}/update_stock', '[email protected]')->name('manager.materials.updatestock');
Route::patch('materials/{id}/update', '[email protected]')->name('manager.materials.update');
Route::get('materials/{id}/destroy', '[email protected]')->name('manager.materials.destroy');
Route::get('assets', '[email protected]')->name('manager.assets.index');
Route::get('assets/{id}/show', '[email protected]')->name('manager.assets.show');
Route::get('assets/create', '[email protected]')->name('manager.assets.create');
Route::post('assets/store', '[email protected]')->name('manager.assets.store');
Route::get('assets/{id}/edit', '[email protected]')->name('manager.assets.edit');
Route::patch('assets/{id}/update', '[email protected]')->name('manager.assets.update');
Route::get('assets/{id}/stock', '[email protected]')->name('manager.assets.stock');
Route::post('assets/{id}/update_stock', '[email protected]')->name('manager.assets.updatestock');
Route::get('assets/{id}/destroy', '[email protected]')->name('manager.assets.destroy');
});
//operator
Route::group(['middleware' => ['auth', 'role:operator']], function() {
//tambah pelanggan
//probably unused
/*
Route::get('clients', '[email protected]')->name('operator.clients.index');
Route::get('clients/{id}/edit', '[email protected]')->name('operator.clients.edit');
Route::patch('clients/{id}/update', '[email protected]')->name('operator.clients.update');
Route::get('clients/{id}/delete', '[email protected]')->name('operator.clients.destroy');
*/
//real operator
// Route::get('clients/create', '[email protected]')->name('operator.clients.create');
Route::get('terimaPelanggan', '[email protected]')->name('operator.terimaPelanggan');
Route::post('clientStore', '[email protected]')->name('operator.clientStore');
Route::get('antrian', '[email protected]')->name('operator.antrian');
Route::get('antrian/{id}/show', '[email protected]')->name('operator.antrian.show');
// Route::get('layarAntrian', '[email protected]')->name('operator.layarAntrian');
Route::get('updateStatus', '[email protected]')->name('operator.updateStatus');
});
//cashier
Route::group(['middleware' => ['auth','role:cashier']], function() {
//pindahan dari operator
Route::get('antrianKasir', '[email protected]')->name('cashier.antrian');
Route::get('antrianKasir/{id}/show', '[email protected]')->name('cashier.antrian.show');
//list transaction in out
Route::get('transactions', '[email protected]')->name('cashier.index');
Route::get('transactions/{id}/show', '[email protected]')->name('cashier.show');
//view detail transaction
// Route::get('transactions/{id}', '[email protected]')->name('operator.show');
//create transaction form
Route::get('transactions/create/{id}', '[email protected]')->name('cashier.create');
Route::get('search/product', '[email protected]')->name('cashier.autocomplete');
Route::get('search/customer', '[email protected]')->name('cashier.autocompleteCustomer');
Route::post('transactions/additem', '[email protected]')->name('cashier.additem');
Route::get('transactions/deleteitem/{id}', '[email protected]')->name('cashier.deleteitem');
Route::post('transactions/clearitems', '[email protected]')->name('cashier.clearitems');
Route::get('transactions/store', '[email protected]')->name('cashier.store');
Route::get('transaction/{id}/export', '[email protected]')->name('cashier.transaction.export');
});
//client
Route::group(['prefix' => 'client', 'middleware' => ['auth', 'role:client']], function() {
//topup
Route::get('/transactions', '[email protected]')->name('client.transaction.index');
Route::get('/transactions/{id}/show', '[email protected]')->name('client.transaction.show');
Route::get('/transactions/{id}/export', '[email protected]')->name('client.transaction.export');
});
有一些測試路線,評論每個角色等等。 我的路線應該如何? 任何幫助將不勝感激。