Configure Template (ready) in Laravel 5.x

0

I'm relatively new to development with laravel. I bought a template (bootstrap) for my system but I do not know how to configure it to work on my application's frontend . I have already tried some tutorials that copy index to welcome and CSS and JS folders to the public folder. I have already changed routes and I have not been successful either, if anyone can help me.

    
asked by anonymous 06.07.2017 / 19:28

1 answer

2

Creating views is relatively simple, have a look at documentation ?

First, create a controller, for example, in the app\Http\Controllers folder, create a file named: homeController, in the contents of your controller, eg:

homeController.php

namespace App\Http\Controllers;
use App\Http\Controllers\Controller;

class homeController extends Controller
{
  public function index()
 {
   return view('home');
 }
}

in the resources/views folder, create a file named home.blade.php Laravel uses the blade to create your templates, in the content of your template, place your html. there will be other things to consider but I will explain only the basics.

Creating routes:

Now in the routes / web.php folder, copy the line:

Route::get('/', function () {
    return view('welcome');
});

and edit it so that it stays this way (if it is not returning the view of the controller):

Example 1:

Route::get('/', function () {
    return view('home');
});

o "/" in get means that this is the home page of the application. if it is to add other routes would be:

Route::get('produtos', function () {
    return view('produtos');
});

If the view (file containing the html) is inside a subfolder, then it would look like:

Route::get('produto', function () {
    return view('produtos.produto');
});

In your case how you would be returning the view of the controller would be:

Example 2:

Route::get('/', 'homeController@index')->name('home');

(small explanation: homeController is the name of your controller, @index is the name of the function that returns the view there on your controller)

If your template has some dynamic pages, for example, you need to return some information from the backend, then create a controller for that page as in example 2, if not, just create a route and return the view on the route as in example 1.

    
06.07.2017 / 19:53