laravel-routing

delete in laravel with get using Route::resource()

浪尽此生 提交于 2019-12-11 20:13:44
问题 I'm trying to delete in laravel using GET instead of DELETE because my shared server doesn't support DELETE verb. So, I used Jeffrey Way's method Thing is in my routes.php, I use Route::resource('users', 'UserController'); For example. So, When I use GET instead of DELETE with resource, system think I will use show method, instead of destroy method. The only way I see to do that is not using resource method to route, and detail all my routes, but I don't like it, it is kind of heavy to read.

Laravel combining routes

帅比萌擦擦* 提交于 2019-12-11 19:41:54
问题 Is there any way of combining these two following routes? Route::get('project/(:any)', 'dashboard.project@(:1)'); Route::get('project/(:any)/(:any)', 'dashboard.project@(:1)'); I'm asking because the second route, I had to add it in order for the following requests to work: site.com/project/new => method site.com/project/view/12351326 => method and parameter 回答1: You can use regex in the first parameter of the get() method to combine those. See section Regular Expression Route Constraints in

Change Base URL in Laravel 5.5

北城余情 提交于 2019-12-11 17:42:10
问题 I 'm trying to change the base URL http://myscreenclass.com/ to http://myscreenclass.com/home . I changed the .env file and updated the config/app.php file as well. I tried to solve the issue many different ways, but nothing happens. How can I change the URL? 回答1: I am trying to change base URL http://myscreenclass.com/ to http://myscreenclass.com/home May I suggest reading up on routing with Laravel? You can achieve this by adding this to your web routes file. Route::redirect('/', '/home');

i want to send data from one view to another Laravel view

三世轮回 提交于 2019-12-11 12:27:44
问题 i have two views, view-1 and view-2. view-1 has form, which will store data temporary. i want to get data from view-1 and send it to view-2 , which has user profile, where temporary data from view-1 will be shown. how we can achieve it in Laravel, i know we can store data in SQL and then fetch it, but how to do it without storing to SQL. my code: view: 1 <form > <div class="form-group"> <label class="col-form-label" >Date</label> <input type="text" name="sdate" class="form-control"> <input

Routes collision in Laravel 4

送分小仙女□ 提交于 2019-12-11 12:19:30
问题 I am working on a project using Laravel 4, I have a "user route" to show user profiles by their username: Route::get("user/{username}", array( 'as' => 'userProfile', 'uses' => 'UserController@getProfile') ); But here I have another route which shows a user's messages. Route::get('user/messages', array( 'as' => 'userMessages', 'uses' => 'MessageController@getMessages') ) But there is a collision here. Laravel thinks "messages" is a username because of first Route. How can I work around this?

get current path outside of Route

安稳与你 提交于 2019-12-11 12:14:25
问题 In this URL: http://siteName/html/test I want to catch test , of course inside the route. This works great: Route::get('test', function() { return Route::getCurrentRoute()->getPath(); }); But I want to access the path outside of any route and in my route.php file like this: // routes.php return Route::getCurrentRoute()->getPath(); Route::get('test', function() { ... }); 回答1: In case you try to catch all routes. Add this as your last route. Route::any('{all}', function($uri) { return Route:

Friendly urls in Laravel , am I doing it right?

a 夏天 提交于 2019-12-11 12:11:30
问题 Here's my route : Route::get('location/{id}/{title?}', array('as' => 'scouting_single', 'uses' => 'ScoutingController@get_single')); The class is simple: public function get_single($id, $title ='') { $location = new Location; if(is_numeric($id)) { $location = $location->find($id); if(isset($location)) { $author = User::find($location->author); $meta = $location->find($id)->metakeywords; if($title == '') { $slug = Str::slug($location->title); return Redirect::to('location/'.$id.'/'.$slug); }

How to embed a Laravel application within another web application?

不想你离开。 提交于 2019-12-11 09:37:01
问题 So I have a web application, say www.randomwebapp.com, and I want www.randomwebapp.com/laravelapp to point to a laravel app I have written. I've already figured out how to include my laravel app as a separate package and access classes within my laravel app, but I'm wondering how to actually go about rendering views/routing etc. I'm mainly concerned with how to actually start running the app (perhaps something to do with bootstrap/app.php or bootstrap/autoload.php). 回答1: I'm assuming you're

Basic Laravel 4 Routing

爷,独闯天下 提交于 2019-12-11 09:29:35
问题 I would like to call a controller with parameters with this kind of configuration: Route::pattern('d', '[0-9]+'); Route::get('/{a}/{b}/{c}/{d}', function($a, $b, $c, $d) { // CALL A METHOD OF A CONTROLLER WITH PARAMETERS }); 回答1: Just call the controller method like this: Route::get('/{a}/{b}/{c}/{d}', 'AnyController@itsMethod'); And in the controller: class AnyController extends BaseController { //... public function itsMethod($a, $b, $c, $d) { ///proceed your params } //... } Laravel passes

Laravel5 OldMiddleware The page isn't redirecting properly

ぃ、小莉子 提交于 2019-12-11 08:58:54
问题 I'm just taking the first look at laravel5 so with a new install I'm starting playing around (as usual :) ) php artisan make:middleware OldMiddleware <?php namespace App\Http\Middleware; use Closure; class OldMiddleware { /** * Run the request filter. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($request->input('age') < 200) { return redirect('home'); } return $next($request); } } <?php namespace