laravel-routing

Install Laravel 5 app in subdirectory with htaccess

自古美人都是妖i 提交于 2019-11-29 09:14:09
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/dashboard instead of nice pretty URLs like: http://www.example.com/myapp/ http://www.example.com/myapp

laravel route filter to check user roles

风格不统一 提交于 2019-11-29 08:53:42
问题 I am building a restful api in laravel 4 where there are users with different types of permission. I want to restrict access to different routes depending on the user role (which is saved in the user table in db) How would I do that? Here is what I have so far (it's not working so far). filters.php //allows backend api access depending on the user's role once they are logged in Route::filter('role', function() { return Auth::user()->role; }); routes.php Route::group(array('before' => 'role'),

How to put route in anchor tag in laravel 5.2

久未见 提交于 2019-11-29 07:55:34
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: You can do this quite simply with the url() helper. Just replace your anchor tag like so: <a id="index"

Get fullUrl in laravel 5.1

心已入冬 提交于 2019-11-29 02:37:04
问题 i have multiple bootstrap tabs where each one do different action from others tabs for exmaple app-url/users#creat-admin-users-tab app-url/users#creat-regular-users-tab Is there any way in Laravel to get full url including the #tab-name Thanks for your time. 回答1: Check the following $_SERVER['HTTP_HOST'] => Host name from the current request. $_SERVER['HTTP'] => Set to a non-empty value if the protocol is HTTP $_SERVER['HTTPS'] => Set to a non-empty value if the protocol is HTTPS $_SERVER[

Laravel : How to hide url parameter?

南楼画角 提交于 2019-11-29 02:25:22
Here the scenario is I want to pass a variable which will be send from one page to another and in next page it's gonna store through a form. So I have passed the variable from first page to second page through the URL. But I want to hide the parameter in the URL. How do I do it? Here is my route : Route::get('/registration/{course_id}',[ 'uses'=>'AppController@getregistration', 'as'=>'registration' ]); And Controller : public function getregistration($course_id) { return view('index')->with('course_id',$course_id); } And first page this is how I send the value to first page: <li> <a href="{

FatalErrorException in HtmlServiceProvider.php line 36: laravel

梦想的初衷 提交于 2019-11-29 01:38:21
I am using laravel 5.2 and I am getting following error FatalErrorException in HtmlServiceProvider.php line 36: Call to undefined method Illuminate\Foundation\Application::bindShared() my app.php file is <?php return [ 'env' => env('APP_ENV', 'production'), 'debug' => env('APP_DEBUG', false), 'url' => 'http://localhost', 'timezone' => 'UTC', 'locale' => 'en', 'fallback_locale' => 'en', 'key' => env('APP_KEY'), 'cipher' => 'AES-256-CBC', 'log' => env('APP_LOG', 'single'), 'providers' => [ /* * Laravel Framework Service Providers... */ Illuminate\Auth\AuthServiceProvider::class, Illuminate

How to make routes in Laravel case insensitive?

十年热恋 提交于 2019-11-29 01:37:17
问题 I have a project in laravel and there are many routes in that project. But i just discovered that the routes are all case sensitive, means /advertiser/reports is different than /advertiser/Reports . So what i want is both the routes should redirect to same view. Currently /advertiser/Reports gives RouteNotFound Exception. I have read about the Route::pattern() way of doing it but since there are many routes i'll have to put in a lot of efforts for that. So, what i want is a better way of

Laravel: How to respond with custom 404 error depending on route

痴心易碎 提交于 2019-11-29 01:29:07
问题 I'm using Laravel4 framework and I came across this problem. I want to display a custom 404 error depending on requested url. For example: Route::get('site/{something}', function($something){ return View::make('site/error/404'); }); and Route::get('admin/{something}', function($something){ return View::make('admin/error/404'); }); The value of '$something' is not important. Shown example only works with one segment, i.e. 'site/foo' or 'admin/foo' . If someone request 'site/foo/bar' or 'admin

How to route to a static folder in Laravel

我们两清 提交于 2019-11-29 00:42:28
问题 I have a folder I've placed in the /public folder in my Laravel site. The path is: /public/test the "test" folder has a file called index.html that is just a static resource I want to load from the public folder (I don't want to create a view for this within the framework--too much to explain). I've made a route like this: Route::get('/test', function() { return File::get(public_path() . '/test/index.html'); }); I'm not able to get this to work. I just get an error from Chrome saying this

How to route GET and POST for same pattern in Laravel?

旧巷老猫 提交于 2019-11-29 00:25:12
问题 Does anyone know of any way in Laravel 4 which combines these 2 lines into one? Route::get('login', 'AuthController@getLogin'); Route::post('login', 'AuthController@postLogin'); So instead of having to write both you only have to write one since their both using the 'same' method but also the URL remains as site.com/login instead of a redirect to site.com/auth/login ? I'm curious since I remember CI has something like that where the URL remains the same and the controller is never shown: