laravel-routing

User Auth not persisting within Laravel package

强颜欢笑 提交于 2019-12-05 04:20:49
This is my first attempt at a laravel package and have run into an issue where Auth::attempt($credentials) works within my login controller, but upon redirection to a protected route or controller, the user is no longer authenticated. Below is my login controller method with the redirect to dashboard commented out. public function attempt(Request $request){ $email = strtolower(strip_tags(htmlspecialchars($request->input('email')))); $password = strip_tags(htmlspecialchars($request->input('password'))); if (Auth::attempt(array('email' => $email, 'password' => $password))) { // Redirect to

Laravel How to remove “api” Prefix from subdomain URL

痴心易碎 提交于 2019-12-04 20:54:48
问题 I have created a Laravel application which is both Web application and provides REST APIs to android and iOS platforms. I have two route files one is api.php and other is web.php and routes\api.php routing as follows: routes/api.php Route::group([ 'domain'=>'api.example.com', function(){ // Some routes .... } ); and nginx serve blocks configured can be seen here server { listen 80; listen [::]:80; root /var/www/laravel/public; index index.php; server_name api.example.com; location / { try

Intercept Laravel Routing

大兔子大兔子 提交于 2019-12-04 17:20:20
I am busy building a Restful API in Laravel 5.1 where the API version is passed through the header. This way I can version the features rather than copy and pasting a whole route group and increment the version number. The problem I'm having is that I would like to have versioned methods, IE: public function store_v1 (){ } I have added a middleware on my routes where I capture the version from the header, but now need to modify the request to choose the correct method from the controller. app/Http/routes.php Route::group(['middleware' => ['apiversion']], function() { Route::post('demo',

Route using either a prefix or a domain

允我心安 提交于 2019-12-04 12:12:50
I am working on a platform that allows users to run their own site in either a sub folder of the main website domain, or map a custom domain for their site. When using a custom domain the URL structure for each route is slightly different in that it is prefixed with the username, but when using a custom domain then this prefix is not used. Is there a clever way to achieve this in my Route::group to handle both request types in one route and successfully use reverse routing to produce the appropriate URL based on the parameters passed to it. Below is an example of using the prefix Route::group

Should I Nest Routes to Resources in Laravel?

99封情书 提交于 2019-12-04 05:20:47
This may be a little subjective, but I feel that best-practice must exist (or even good design when it comes to Laravel apps). Googling results in lots of things that are not to do with the actual points in this question. Say I am building a web application that has teams, which may have projects, which may have documents. Should I design the routing so that documents are within the path of the projects they belong to, which are then within the path of the teams they belong to, or keep things at a top level? As far as I can tell, there are two ends to this spectrum that are worth discussing

Routes not working without index.php

让人想犯罪 __ 提交于 2019-12-04 01:17:25
Im using laravel 4. I have a view nest.blade.php and the corresponding controller NestController.php: Controller content: class NestController extends BaseController { public function showView() { return View::make('nest'); } } Route: Route::get('/nest', 'NestController@showView'); When I go to url/nest it doesnt work. When I go to url/index.php/nest it does work. Obviously I just want it to be /nest without the index.php. How can i resolve this? My htaccess: IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On # Redirect Trailing Slashes...

Dynamic middleware for laravel 5

試著忘記壹切 提交于 2019-12-03 17:52:01
问题 While building multi-tenancy packages for Laravel 5 I had to find out how to add middleware dynamically from code. In comparison to this question on SO I do not want to touch the Http/Kernel definitions. During application initialization I check whether the requested hostname is known in the database and whether this hostname requires a redirect to a primary hostname or ssl. Because you don't want to touch the Http/Kernel as a package, we need to use the service provider. Requirements:

Laravel Route model binding with relationship

你离开我真会死。 提交于 2019-12-03 16:52:22
问题 I am wondering if it is possible to return a relationship with laravels Route model binding ? Say is a have a user model with a relationship 'friends' to other users, and I want to return both the user info and the relationship from a route or controller. eg for the route domain.tld/user/123 Route::model('user', 'User'); Route::get('/user/{user}', function(User $user) { return Response::json($user); }); this will return me the user info fine but I also want the relationships, is there any

Laravel How to remove “api” Prefix from subdomain URL

非 Y 不嫁゛ 提交于 2019-12-03 14:47:07
I have created a Laravel application which is both Web application and provides REST APIs to android and iOS platforms. I have two route files one is api.php and other is web.php and routes\api.php routing as follows: routes/api.php Route::group([ 'domain'=>'api.example.com', function(){ // Some routes .... } ); and nginx serve blocks configured can be seen here server { listen 80; listen [::]:80; root /var/www/laravel/public; index index.php; server_name api.example.com; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi

Laravel - CNAME + Subdomain Routing

痴心易碎 提交于 2019-12-03 08:59:36
I have my routes set up as follows: <?php Route::group([ 'domain' => '{username}.u.'.env('APP_DOMAIN'), ], function () { Route::get('/', 'FrontendController@site'); }); Route::group([ 'domain' => env('APP_DOMAIN'), ], function () { // Regular site routes }); Route::group([ 'domain' => '{domain}', ], function () { Route::get('/', 'FrontendController@domain'); }); What I'm trying to achieve is allowing users to have their own sites, e.g. hello.u.domain.com, and for those sites to also be served through a custom domain that is CNAME'd to their subdomain. Using the routing above, the wildcard