Search
 
SCRIPT & CODE EXAMPLE
 

PHP

add a controller method in laravel routes

//adding a Controller's path with method  in laravel route.
//say Controller is 'PagesController'
//create controller: in terminal: php artisan make:controller PagesController
// -> app/Http/Controller/PagesController.php
//use ....
//use ,..
class PagesController{

	public function index(){
    	$data = [
        	'title' => 'Home'
        ];
      //for home.blade.php
      return('home', compact('data'));
    }
}

//create home.blade.php file in routes/
//->routes/home.blade.php
echo $data['title'];
//->routes/web.php
	Route::('/', 'AppHttpControllerPagesController@index'); //using index() method
Comment

PREVIOUS NEXT
Code Example
Php :: how to give optional parameter in route 
Php :: return with success message laravel 
Php :: how to get meta information from pagination in laravel controller 
Php :: phpunit test private function 
Php :: maatwebsite/excel package 5.2 laravel 
Php :: ziparchive php example 
Php :: php file_put_contents inode problem 
Php :: convert multdimentional array in array in php 
Php :: php last item of array 
Php :: php sort() 
Php :: php validate colour 
Php :: luhn algorithm 
Php :: real time update using ajax php 
Php :: get cookie in laravel 
Php :: $_SESSION php example 
Php :: ?? Null Coalescing Operator PHP 
Php :: php sort array remove keys 
Php :: php != operator 
Php :: Multiple image upload with CodeIgniter 
Php :: update checkbox value in laravel 
Php :: lenght de un array php 
Php :: laravel module package 
Php :: php mail template 
Php :: html in php function 
Php :: laravel validation check value should be one of in array 
Php :: codeigniter validation text length 
Php :: switch between php version ubuntu 
Php :: smarty php 
Php :: find object in array php 
Php :: saving an image from pc to php 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =