In Laravel Let's go with the example using controller name is Product
1. Create controller in Controllers case sensitive name so, create like a example given example : ProductController.php
2. Create view in views create like a example product
Edit web.php
//route file name
<project_name>/routes/web.php
Add this content to web.php
here, we can use any name in the url to call like http://127.0.0.1:8000/product or we can give name anyother like http://127.0.0.1:8000/Products also, with replace name in route file also.
//controller path
<project_name>/app/Http/Controllers/ProductController.php
5. Add this code to view in Views use as you created your view name here we created product.blade.php
//view path
<project_name>/resources/views/product.blade.php
//route file name
<project_name>/routes/web.php
1. Create controller in Controllers case sensitive name so, create like a example given example : ProductController.php
//controller pathExample product controller<project_name>/app/Http/Controllers/<controller_name.php>
//controller path<project_name>/app/Http/Controllers/ProductController.php
2. Create view in views create like a example product
Example product view//view path<project_name>/resources/views/<view_name>.blade.php
//view path3. Add Path to the routes file web.php<project_name>/resources/views/product.blade.php
Edit web.php
//route file name
<project_name>/routes/web.php
Add this content to web.php
Example Product view explain to this how it work with the example//hereRoute::get('/<name_controller>', '<controller_name>@index');
here, we can use any name in the url to call like http://127.0.0.1:8000/product or we can give name anyother like http://127.0.0.1:8000/Products also, with replace name in route file also.
Route::get('/product', 'ProductController@index');4. Example Product Add this code to the controller use as you created your controller name here we created ProductController.php
//controller path
<project_name>/app/Http/Controllers/ProductController.php
<?phpnamespace App\Http\Controllers;use Illuminate\Http\Request;class ProductController extends Controller{/*** Show the application dashboard.** @return \Illuminate\Contracts\Support\Renderable*/public function index(){return view('product');}}
5. Add this code to view in Views use as you created your view name here we created product.blade.php
//view path
<project_name>/resources/views/product.blade.php
6. Add this code to web.php if you not added and if you given any other name of controller replace with it@extends('layouts.app')@section('content')<div class="container"><div class="row justify-content-center"><div class="col-md-8"><div class="card"><div class="card-header">Product</div><div class="card-body">@if (session('status'))<div class="alert alert-success" role="alert">{{ session('status') }}</div>@endifWelcome To the Product!</div></div></div></div></div>@endsection
//route file name
<project_name>/routes/web.php
Route::get('/product', 'ProductController@index');
7. Call from URL//used php artisan servehttp://127.0.0.1:8000/product
//without php artisan servehttp://localhost/panel/public/product/ORhttp://localhost/panel/server.php/product
Laravel Development Company, Get a free quote for laravel web development requirement from a leading Laravel Development Company. Discuss your web project with us to get large discounts...Contact us : +91-9806724185 or Contact@expresstechsoftwares.com
ReplyDelete