laravel-routing

Get laravel current route group in middleware

╄→гoц情女王★ 提交于 2019-12-10 18:13:43
问题 Is there a way to get the parent route group of current route in Laravel middlewares? public function handle($request, Closure $next, $guard = null) { // here I mean } 回答1: You can't get the group from a route, especially that you can nest groups within other groups. The easiest way to be able to tell which group current request belongs to would be to add a parameter to your middleware - see the docs for more details here: https://laravel.com/docs/5.2/middleware#middleware-parameters First,

Laravel - Overriding a resource route into a different route filter group

旧街凉风 提交于 2019-12-10 17:47:15
问题 Laravel's routing doesn't seem to be working as expected? From what I understand, if I intend to override a route, all I need to do is to put the expected route before the other one. What I have is something like this: Route::group(array('before'=>'defaultLoads'), function(){ Route::post('newsletter', 'NewsletterController@store'); Route::group(array('before'=>'login'), function(){ Route::resource('newsletter','NewsletterController'); } }); Which I assumed that if i post to this route http:/

Remove csrf token only for single method - Laravel

蓝咒 提交于 2019-12-10 17:17:59
问题 I am using paytabs payment gateway api. In that api, a redirect url have to given, so that once the transaction is completed, the page will redirect automatically to your given redirect url. The url was a GET url but since the response of the api comes as a POST type, I was unable to use get url. To resolve that issue, I made that route a POST url but by making it post method, I am not getting any CSRF token. In the end, I get this issue. TokenMismatchException in VerifyCsrfToken.php line 68:

Laravel 5.3 Route model binding with multiple parameters

一曲冷凌霜 提交于 2019-12-10 16:39:31
问题 Is it possible to have route model binding using multiple parameters? For example Web Routes: Route::get('{color}/{slug}','Products@page'); So url www.mysite.com/blue/shoe will be binded to shoe Model, which has color blue. 回答1: First of all, it would feel more natural to have a route like the following: Route::get('{product}/{color}', 'Products@page'); and to resolve product by route binding, and just use the color parameter in the controller method directly, to fetch a list of blue shoes

Laravel 5.1 routing not working except '/'

倾然丶 夕夏残阳落幕 提交于 2019-12-10 15:59:53
问题 I have created a new laravel project in /var/www/polyforms.me and created virtual host file polyforms.conf : <VirtualHost *:80> ServerName polyforms.dev ServerAdmin webmaster@localhost DocumentRoot /var/www/polyforms.me/public ErrorLog ${APACHE_LOG_DIR}/polyforms.me-error.log CustomLog ${APACHE_LOG_DIR}/polyforms.me-access.log combined </VirtualHost> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet When I go to polyforms.dev it opens home page as it should, but when I go to let's say polyforms

Is there a way to exclude a route from CSRF protection from within a package in Laravel 5?

馋奶兔 提交于 2019-12-10 13:36:25
问题 I am aware of the $except property of the VerifyCsrfToken middleware ( app/Http/Middleware/VerifyCsrfToken.php ) but I am looking for a way to do something similar from my package (so the users who install it don't have to modify their VerifyCsrfToken.php for my route to work). I am able to define routes on my package but I have no idea how to exclude one (or more) of them from the default middleware. I have tried extending Illuminate\Foundation\Http\Middleware\VerifyCsrfToken on my own

The basics of php routing

荒凉一梦 提交于 2019-12-10 12:19:06
问题 I'm looking for a tutorial or explaination on how to do very basic php routing. For example when I visit a link like: mywebsite.com/users I want to run the get method of a route class to provide the data, in the same way laravel does it. Route::get('users', function() { return 'Users!'; }); Can somebody explain how to do this or provide me with some more information? 回答1: In its most common configuration, PHP relies on the web server to do the routing. This is done by mapping the request path

Laravel/PHP - returning/redirecting from child class

…衆ロ難τιáo~ 提交于 2019-12-10 10:41:28
问题 This is my child controller: class VolunteersController extends \BaseController { public function index() { $this->checkForRoles(['admin']); //list some secret stuff for admin } } In my base controller I did this: class BaseController extends Controller { protected function checkForRoles($roles) { foreach ($roles as $role) { if (!(Auth::user()->hasRole($role))) { return Redirect::to('/'); } } } } Now what I expected was that the line return Redirect::to('/'); in BaseController would redirect

Routing Issue, Calling Controller based on Variables in URL- Laravel 4

白昼怎懂夜的黑 提交于 2019-12-08 10:24:51
问题 I am developing an application with Laravel 4 what I need to do is this: let's say I have the following route: Route::get('/myroute/{entity}/methodname', ); Inside it I need to decide based on the entity variable which Controller and method should be called for example: 'MyNameSpace\MyPackage\StudentController@methodname' if the entity == Student and call the 'MyNameSpace\MyPackage\StaffController@methodname' if the entity == Staff how in can be done in Laravel 4 routing is it possible at all

Laravel 5.2 - Every route redirects to the homepage

房东的猫 提交于 2019-12-08 08:59:24
问题 I just started an laravel 5.2 application. Every route I take (/register, /logout, login,...) redirects me to the homepage. Here are my routes <?php Route::group(['middleware' => ['web']], function () { //Register Route::get('/register', 'Auth\AuthController@getRegister'); Route::get('/register/success', 'Auth\AuthController@getRegisterSuccess'); Route::post('/register', 'Auth\AuthController@PostRegister'); //Login Route::get('/login', 'Auth\AuthController@getLogin'); Route::post('/login',