Após a execução dos comandos Artisan para realizar as Migrations do banco de dados. Agora vamos criar as rotas e posteriormente vamos criar o Model do sistema.
Criando as Rotas
Dentro do arquivo ‘routes/web.php’ adicione as seguintes linhas:
//AccountPlans
Route::resource('/accountPlan', 'AccountPlanController');
Route::get('/accountPlan/{id}', 'AccountPlanController@show');
//Balances
Route::resource('/balance', 'BalanceController');
Route::get('/balance/{id}', 'BalanceController@show');
//Banks
Route::resource('/bank', 'BankController');
Route::get('/bank/{id}', 'BankController@show');
//Boxes
Route::resource('/box', 'BoxController');
Route::get('/box/{id}', 'BoxController@show');
//Cards
Route::resource('/card', 'CardController');
Route::get('/card/{id}', 'CardController@show');
//Costs
Route::resource('/cost', 'CostController');
Route::get('/cost/{id}', 'CostController@show');
//Customers
Route::resource('/customer', 'CustomerController');
Route::get('/customer/{id}', 'CustomerController@show');
//DocumentTypes
Route::resource('/documentType', 'DocumentTypeController');
Route::get('/documentType/{id}', 'DocumentTypeController@show');
//EventTypes
Route::resource('/eventType', 'EventTypeController');
Route::get('/eventType/{id}', 'EventTypeController@show');
//Knowledge
Route::resource('/knowledge', 'KnowledgeController');
Route::get('/knowledge/{id}', 'KnowledgeController@show');
//MovementBanks
Route::resource('/movementBank', 'MovementBankController');
Route::get('/movementBank/{id}', 'MovementBankController@show');
//MovementBoxes
Route::resource('/movementBox', 'MovementBoxController');
Route::get('/movementBox/{id}', 'MovementBoxController@show');
//MovementCards
Route::resource('/movementCard', 'MovementCardController');
Route::get('/movementCard/{id}', 'MovementCardController@show');
//MovementChecks
Route::resource('/movementCheck', 'MovementCheckController');
Route::get('/movementCheck/{id}', 'MovementCheckController@show');
//Movements
Route::resource('/movement', 'MovementController');
Route::get('/movement/{id}', 'MovementController@show');
//Parameters
Route::resource('/parameter', 'ParameterController');
Route::get('/parameter/{id}', 'ParameterController@show');
//Plannings
Route::resource('/planning', 'PlanningController');
Route::get('/planning/{id}', 'PlanningController@show');
//Plans
Route::resource('/plan', 'PlanController');
Route::get('/plan/{id}', 'PlanController@show');
//Providers
Route::resource('/provider', 'ProviderController');
Route::get('/provider/{id}', 'ProviderController@show');
//Regs
Route::resource('/reg', 'RegController');
Route::get('/reg/{id}', 'RegController@show');
//Roles
Route::resource('/role', 'RoleController');
Route::get('/role/{id}', 'RoleController@show');
//Transfers
Route::resource('/transfer', 'TransferController');
Route::get('/transfer/{id}', 'TransferController@show');
//Users
Route::resource('/user', 'UserController');
Route::get('/user/{id}', 'UserController@show');
Criando os Models
php artisan make:model Knowledge
php artisan make:model Plan
php artisan make:model Role
php artisan make:model Parameter
php artisan make:model User
php artisan make:model AccountPlan
php artisan make:model Cost
php artisan make:model DocumentType
php artisan make:model EventType
php artisan make:model Bank
php artisan make:model Box
php artisan make:model Card
php artisan make:model Customer
php artisan make:model Provider
php artisan make:model Planning
php artisan make:model Transfer
php artisan make:model Movement
php artisan make:model MovementCheck
php artisan make:model MovementBank
php artisan make:model MovementBox
php artisan make:model MovementCard
php artisan make:model Balance
php artisan make:model Reg
O framework identifica que o Model foi criado no singular e as tabelas estão no plural, seguindo o padrão do framework. Porém, é aconselhavel adicionar a seguinte linha dentro dos Models criados. Vamos atualizar o ‘app/Knowledge.php’:
protected $table = ‘knowledge’;
Criando os Controllers
php artisan make:controller KnowledgeController --resource
php artisan make:controller PlanController --resource
php artisan make:controller RoleController --resource
php artisan make:controller ParameterController --resource
php artisan make:controller UserController --resource
php artisan make:controller AccountPlanController --resource
php artisan make:controller CostController --resource
php artisan make:controller DocumentTypeController --resource
php artisan make:controller EventTypeController --resource
php artisan make:controller BankController --resource
php artisan make:controller BoxController --resource
php artisan make:controller CardController --resource
php artisan make:controller CustomerController --resource
php artisan make:controller ProviderController --resource
php artisan make:controller PlanningController --resource
php artisan make:controller TransferController --resource
php artisan make:controller MovementController --resource
php artisan make:controller MovementCheckController --resource
php artisan make:controller MovementBankController --resource
php artisan make:controller MovementBoxController --resource
php artisan make:controller MovementCardController --resource
php artisan make:controller BalanceController --resource
php artisan make:controller RegController --resource
É necessário informar no arquivo do Controller a localização do Model. Para isso, adicione a seguinte linha, abaixo do namespace, em cada arquivo, como no exemplo seguinte ‘app/Http/Controllers/AccountPlanController.php’:
use App\Knowledge;
Esse projeto possui todo o código disponível em https://github.com/Maksoud/reiniciando e o projeto está hospedado em https://reiniciando.maksoud.dev/. Deixe seu comentário abaixo e colabore com esse projeto.
Você precisa fazer o login para publicar um comentário.