laravel-routing

Laravel 4 : How to pass multiple optional parameters

不打扰是莪最后的温柔 提交于 2019-11-29 00:02:23
I am new to laravel and I am really struggling to understand how to pass multiple optional url parameters. What is the standard way to code routes when passing 3 optional parameters to the controller? Also is there a way to code a route to allow named parameters to be passed to the controller? such as public/test/id=1&page=2&opt=1 or public/test/id=1/page=2/opt=1 Thanks for any help Razor If you have multiple optional parameters Route::get('test',array('as'=>'test','uses'=>'HomeController@index')); And inside your Controller class HomeController extends BaseController { public function index()

debugging laravel artisan from PHPStorm with homestead

蹲街弑〆低调 提交于 2019-11-28 19:40:01
I setup Laravel Homestead. I then configured both homestead xdebug.ini and PHPStorm to make the debugging work. Here is my xdebug.ini inside homestead zend_extension=xdebug.so xdebug.remote_autostart = on xdebug.remote_enable = on xdebug.remote_connect_back = on xdebug.remote_port = 9000 xdebug.idekey = "vagrant" To start a debugging session the steps I follow are In PHPStorm --> Start Listening for connections In PHPStorm set a breakpoint In my browser --> Use XDebug Chrome Helper OR add to my URL ?XDEBUG_SESSION_START= Load the page This works perfectly. My problem is when I'm inside

post request not working Laravel 5

北城以北 提交于 2019-11-28 14:41:59
I am trying to submit a form using post method, but it does not seem to be working. I have enabled error debug on but still no error is shown. After submitting the form the same page is loaded without any errors. This is my route Route::post('/home' , ['as' => 'store-post' , 'uses'=>'FacebookControllers\PostsController@save']); And my form is {!! Form::open(['route'=>'store-post' , 'class'=>'form'])!!} <div class="form-group"> <label for="textarea"></label> <textarea class="form-control" rows="5" name="textarea">What's on your mind?</textarea> </div> <div class="form-group col-sm-12"> <input

Laravel 5.2 : Web middleware is applied twice

落花浮王杯 提交于 2019-11-28 14:38:51
Here is my routes.php code Route::auth(); Route::group(['middleware' => 'web'], function () { Route::group(['namespace' => 'Admin', 'prefix' => 'admin', 'middleware' => ['auth','role:Admin']], function(){ Route::get('/home', 'HomeController@index'); Route::get('user/data', ['as' => 'admin.user.data','uses'=>'UserController@userData']); Route::resource('user', 'UserController'); Route::get('merchant/data', ['as' => 'admin.merchant.data','uses'=>'MerchantController@merchantData']); Route::resource('merchant', 'MerchantController'); Route::get('bcategory/data', ['as' => 'admin.bcategory.data',

Laravel 5.2 Missing required parameters for [Route: user.profile] [URI: user/{nickname}/profile]

自作多情 提交于 2019-11-28 08:24:47
I keep getting this error ErrorException in UrlGenerationException.php line 17: When ever any page loads and I'm logged in. Here is what my nav looks like @if(Auth::guest()) <li><a href="{{ url('/login') }}">Log In</a></li> <li><a href="{{ url('/register') }}">Sign Up</a></li> @else <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ Auth::user()->nickname }}<span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="{{ route('user.profile') }}">Profile</a></li> <li><a href="{{ route('user

Method not allowed when PUT used over AJAX for Laravel resource

我们两清 提交于 2019-11-28 07:21:49
问题 I've got this resource in routes.php: Route::resource('items', 'ItemsController', ['before' => 'admin_access']); Trying to reach ItemsContoller@update method through AJAX but it's kicking out a 405 Method not allowed error: var $inputs = $('input', row); var id = $(row).find('.edit').data('id'); var data = $inputs.serializeJSON(); data['_token'] = $('input[name=_token]').val(); data['_method'] = 'PUT'; console.debug(data); $.ajax({ url: 'items/' + id, method: 'PUT', dataType: 'json', data:

Install Laravel 5 app in subdirectory with htaccess

穿精又带淫゛_ 提交于 2019-11-28 02:40:13
问题 The Setup I am trying to install a laravel 5 app in this directory on my server: public_html/myapp/ And I want it to be accessed at this URL: http://www.example.com/myapp/ I have created this .htaccess rule and placed it in the myapp folder in order to redirect requests : RewriteEngine on RewriteRule ^(.*)$ public/$1 [L] Problem: In my browser when I try to access the app I get redirected URLs like: http://www.example.com/myapp/public/index.php http://www.example.com/myapp/public/index.php

Laravel Route issues with Route order in web.php

一个人想着一个人 提交于 2019-11-28 01:43:50
问题 I have problem with routes in Laravel, I'm following one tutorial and we have this routes listed in web.php file Route::get('/home', 'HomeController@index')->name('home'); Route::get('/blog', 'BlogController@index')->name('blog'); Route::get('/blog/create', 'BlogController@create'); Route::post('/blog/store', 'BlogController@store'); Route::get('/blog/{id}', 'BlogController@show'); Route::get('/blog/{id}/edit', 'BlogController@edit'); Route::patch('/blog/{id}', 'BlogController@update'); Route

How to put route in anchor tag in laravel 5.2

时间秒杀一切 提交于 2019-11-28 01:02:05
问题 I've gone through many of the articles below, which explains generating link from named route, but unable to solve my problem. Tutorial 1 Tutorial 2 Tutorial 3 Following is the defined routes: Route::get('/nitsadmin/dashboard', function () { return view('nitsadmin.dashboard'); }); And I'm calling link in anchor tag: <a id="index" class="navbar-brand" href="{{Html::linkRoute('/nitsadmin/dashboard')}}"> <img src="../img/admin/nitseditorlogo.png" alt="Logo"> </a> I'm getting following error: 回答1

Redirect to homepage if route doesnt exist in Laravel 5

天大地大妈咪最大 提交于 2019-11-27 19:08:27
/** Redirect 404's to home *****************************************/ App::missing(function($exception) { // return Response::view('errors.missing', array(), 404); return Redirect::to('/'); }); I have this code in my routes.php file. I am wondering how to redirect back to the home page if there is a 404 error. Is this possible? William Langlois For that, you need to do add few lines of code to render method in app/Exceptions/Handler.php file which looks like this: public function render($request, Exception $e) { if($this->isHttpException($e)) { switch ($e->getStatusCode()) { // not found case