Menu
  • HOME
  • TAGS

How to use the request route parameter in Laravel 5 form request?

php,laravel,laravel-5,laravel-routing,laravel-validation

That's very simple, just use the route() method. Assuming your route parameter is called id: public function authorize(){ $id = $this->route('id'); } ...

Laravel Saving data

laravel-4,laravel-routing

Any Way I find My answer myself. I use thos code below for ($j=1; $j <=6; $j++) { $routine=new RoutineCreate; $routine->configuration_id=$idcnfg; $routine->day=Input::get('day' . $j); for ($i=1; $i <=10; $i++) { $pi="p" . $i; $countCourseTeacher++; $routine->$pi=Input::get('course_teacher' . $countCourseTeacher); } $routine->save(); ...

Laravel 5 - redirect to HTTPS

php,laravel,laravel-routing,laravel-5

You can make it works with a Middleware class. Let me give you an idea. namespace MyApp\Http\Middleware; use Closure; class HttpsProtocol { public function handle($request, Closure $next) { if (!$request->secure() && env('APP_ENV') === 'prod') { return redirect()->secure($request->getRequestUri()); } return $next($request); } } Then, apply this middleware to every request adding...

Zizaco\Entrust for Laravel test multiple roles at time

php,laravel,roles,laravel-routing,third-party-code

Sorry for my rude answer of before. https://github.com/Zizaco/entrust sais: More advanced checking can be done using the awesome ability function. It takes in three parameters (roles, permissions, options). roles is a set of roles to check. permissions is a set of permissions to check. Either of the roles or permissions...

Laravel 4 - Improve code to check for Authentication

php,laravel,laravel-4,laravel-routing,code-cleanup

Use Route Groups and Auth Filters. http://laravel.com/docs/4.2/routing#route-groups http://laravel.com/docs/4.2/security#protecting-routes Example Route::group(array('before' => 'auth'), function() { // Route::resource('poll', 'PollController'); // Additional routes } Here is a great tutorial series on Laravel in general (and your topic); http://culttt.com/2013/09/16/use-laravel-4-filters/...

Laravel 5 - Routes and variable parameters in controllers

php,laravel,laravel-5,laravel-routing

You can use the Route::current() method to access the current route and get parameters by name via the getParameter method. However there is a problem with your route definitions, which would make the last two routes defined useless. Because the page parameter in your last two routes is optional, depending...

How to change password reset messages in laravel 5?

laravel,laravel-routing,laravel-5

The default messages for Laravel 5 are stored in /resources/lang/en/passwords.php. Remember that you can also always override these with custom messages when validating. Check out the documentation for the validation....

Laravel 5 MethodNotAllowedHttpException

php,laravel,laravel-5,laravel-routing

Your <a> link will trigger a GET request, not a PATCH request. You can use JS to have it trigger a PATCH request, or use a <button> or <input type="submit"> to issue one.

Auth is not working in Laravel

php,laravel,laravel-4,laravel-routing

The password not in hashed. if (Auth::attempt(array('username' => $username, 'password' => $password), true)) ...

Laravel route model

php,laravel,laravel-routing

Route::get('cats/{cat}' will "catch" /cats/create because the {cat} part in the one route matches anything. No only id's but also create. You can either change the order to this to have the more restricted route (cats/create) before the less restricted one (cats/{cat}) or you can use regex to allow only numbers...

Laravel 5 - before auth not working

php,laravel,laravel-5,laravel-routing

In laravel 5, ['before' => 'auth'] is deprecated. But instead, I should use ['middleware' => 'auth']...

Laravel and PSR 4 Autoloading not working

php,laravel,laravel-routing,laravel-5

I believe in your case the namespace would be: <?php namespace EP; ...

405 Error when trying to send email via route with Laravel

php,email,laravel,laravel-4,laravel-routing

By default the Form helper will generate a html form that uses the POST method. You can specify the method if you need to use a different one: {{ Form::open(array('url' => 'admin/newemail', 'method' => 'GET')) }} Or you could also change your route to match POST requests: Route::post('admin/newemail', function() {...

Laravel login and admin panel (after successful authentication) pages both on “/”

session,laravel-4,laravel-routing

Have you tried putting homeLogin within a guest group? So like... Route::group(['before' => 'guest'], function() { Route::get('/', ['as' => 'homeLogin', 'uses' => '[email protected]']); }); Otherwise you can manually check this in your controller/route programatically: if(!Auth::user()) { return View::make('guest.page'); } For further info, check this answer also: Laravel 4: Two different...

Set session variable in laravel

php,laravel,session-variables,laravel-routing,application-variables

The correct syntax for this is... Session::set('variableName', $value); To get the variable, you'd use... Session::get('variableName'); If you need to set it once, I'd figure out when exactly you want it set and use Events to do it. For example, if you want to set it when someone logs in, you'd...

Working with Laravel routes

laravel,laravel-5,laravel-routing

Maybe because second URL has uppercase characters?

Laravel Passing Validation Errors to View

php,laravel,laravel-4,laravel-routing,laravel-validation

After looking into this issue for two whole days - I've finally fixed it! In the end I removed the vendor folder and ran composer update. I can only assume that something within Laravel was corrupt in the initial download.

Laravel 5 - Nest Resource index method resource ID

php,laravel,laravel-5,laravel-routing,nested-resources

Apparently you're doing it right. What do you mean when you say you get {photos}? Is the photo_id in the URL? Like photos/1/comments? Here's how I do it and it works: route.php Route::resource('users.stuff' ,'StuffController'); StuffController.php public function index($uid, Request $request) { //$uid contains the user id that is in the...

How to create a filter for a domain in Laravel

laravel,laravel-4,laravel-routing

To make this work, I needed to change: Route::group(['domain' => Config::get('domains.main')], function () { To: Route::group(['domain' => Config::get('domains.main'), 'before' => 'domain'], function () { I also needed to add redirect loop protection to this line: if (Auth::check()) { So that it becomes: if (Auth::check() && !strpos(Request::fullUrl(), 'account/error')) { ...

Routing in laravel 5 with resource

php,laravel-5,laravel-routing

This part is fine I guess as you said you needed it in different directories Route::resource('partner/register', 'PartnerController\Register'); But to get the store route use {!! Form::open(['url' => route('partner.register.store')]) !!} Btw you can see all the current routes with php artisan route:list...

Keep form values when redirect back in Laravel 4

forms,redirect,laravel,laravel-4,laravel-routing

if ($validator->fails()){ return Redirect::back()->withErrors($validator); } change to, if ($validator->fails()){ return Redirect::back()->withErrors($validator)->withInput(); } you can retreive the value by Input::old() method. read more you tried: return Redirect::back()->withErrors($validator)->with('nameValue', Input::get('myName')); above, you can get the value from Session. Session::get('nameValue')...

Why does this Laravel5 ressource route 404?

laravel,laravel-5,laravel-routing

localhost/blog/public/index.php?tasks You must pass all requests through /public/index.php Best way to do this is set DocumentRoot to /public/index.php/ and add entry to hosts file with simple domain eg. laravel.app mapped to 127.0.0.1...

Laravel-5 Redirect Loop [SOLVED]

php,laravel,redirect,laravel-5,laravel-routing

I solved this problem. Under the public folder exist a folder with name is admin. So i changed my rotation like this: Route::group(['middleware' => ['auth', 'perm'], 'prefix' => 'adminpanel'], function(){ Route::get('/', ['as' => 'admin', 'uses' => 'Admin\[email protected]']); Route::resource('kategori', 'Admin\KategoriController'); Route::resource('icerik', 'Admin\ContentController'); // Property Routes Route::resource('property', 'Admin\PropertyController'); Route::post("property/lang", ['uses' =>...

What does “as” keyword really mean in Laravel routing?

laravel,laravel-routing

The purpose isn't for re-direction in your routing file. Instead, with the example route you provided, Laravel will allow you to reference said route by using: $url = route('profile'); Rather then having to build the url manually in your code. So, in short: the difference is the first thing is...

Redirect in Route Service Provider

php,redirect,laravel,laravel-routing,laravel-5

I don't particularly like this way but you can trigger the redirect without having it to return from a controller action or route closure by calling send() on it. (That works for all kind responses by the way) if ($tag->slug !== \Request::segment(3)) { redirect('/tags/' . $tag->id . '/' . $tag->slug)->send();...

LARAVEL use single form for both Edit and Insert actions

php,laravel,laravel-4,laravel-routing

form in view must be like with this code : {{ Form::model($customers,array('route' => array('customers.update', $customers->id))) }} and your Form::text must be like with: {{ Form::text('name', $customers->name, array('class'=>'form-control rtl' ) ) }} Route: Route::controller( 'customers', 'customersController', array( 'getIndex' => 'customers.index', 'postUpdate' => 'customers.update' ) ); now in controller you can try...

Multi-lingual site in Laravel 5

php,laravel,laravel-5,laravel-routing

There is some pretty good documentation on this found here http://laravel.com/docs/5.0/localization The concept is fairly simple. You create a subdirectory for each language you wish to support and within that subdirectory, you add files which contain the language you wish to the support. You then use the Lang class which...

Laravel 5 HTTP/Requests - pass url parameter to the rules() method

laravel-routing,laravel-5,laravel-request

You can retrieve route parameters by name with input(): $id = Route::input('id'); return [ // ... 'slug' => 'required|unique:articles,id,' . $id, // ... ]; It's right there in the docs (scroll down to Accessing A Route Parameter Value)...

How to avoid Reflection Exception in Laravel's project and what are the causes which produce it?

php,laravel,laravel-5,laravel-routing

Take a look to the composer autoload's value: "autoload": { "classmap": [ "database" ], "psr-4": { "App\\": "app/" } }, This means that your namespace for all classes inside of app\ folder should be start with 'App\' as name. In your case, the error states: Fatal error: Uncaught exception 'ReflectionException'...

Laravel 4 Paypal IPN Not Working TokenMismatchException

php,laravel,paypal-ipn,laravel-routing

Just by taking my IPN routes out of the "before auth" group, it seems to be working fine now? Someone did mention something about the csrf being enabled by default on post routes. So that could have something to do with it as well. Just in case, I used their...

simple Laravel View::make() not working

php,laravel,laravel-routing

New syntax for Laravel 5 public function home() { return view('home'); } For more information you can read it from here http://laravel.com/docs/5.0/views...

Laravel view is not getting session data

php,session,laravel,laravel-4,laravel-routing

You don't need to use Session to get user-requested variable in view, just use it simple something like this. @if(isset($user-requested)) @else @endif To put data in session you have to use Session::put('key','value'). The only way the variables are set in Sessions using with() is when they are used with redirects....

Whoops! There was an error. NotFoundHttpException

laravel,laravel-4,laravel-routing

The actual problem is that for some reason the two rewrite conditions: RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f Are not working correctly with your requests. They should prevent that file requests are proxied off to Laravel. It also seems to be environment related. (On my local server it worked perfectly...

Laravel 4 Namespaces routes and namespaces in controllers

php,laravel,laravel-4,laravel-routing

Your controller is in the admin namespace, and referring to other classes from there will be relative to that namespace. So you need to refer to your model with a preceding backslash (just like you did with BaseController) like this: <?php namespace admin; class ScholarGroupController extends \BaseController { public function...

Passing a param containing a path to a controller

laravel,laravel-4,routes,parameter-passing,laravel-routing

You are actually posting two variables. Try this instead Route::post('/download/{myFolder}/{myFile}', array('uses' => '[email protected]', 'as' => 'download')); and in your controller public function download($myFolder, $myFile){ return Response::download($myFolder.'/'.$myFile); } ...

Request::getQueryString() without some parameters

laravel,laravel-5,laravel-routing,laravel-request

Well getQueryString() just returns a string. Instead you can use Request::except() directly and then call http_build_query() to generate the query string: <li><a href="/teachers?{{ http_build_query(Request::except('page')) }}">Teachers</a></li> Note that if you have POST values, those will be included too. If you want to avoid that do this: <li><a href="/teachers?{{ http_build_query(array_except(Request::query(), 'page')) }}">Teachers</a></li>...

Laravel 5 assigning middleware to all sub urls

php,laravel,laravel-routing

Route::group(['prefix' => 'admin', 'middleware' => 'admin'], function() { Route::get('profiles', '[email protected]'); Route::get('pages', '[email protected]'); }); Read more about route groups: http://laravel.com/docs/5.0/routing#route-groups...

Laravel - Path of page from which request was made

laravel-5,laravel-routing,laravel-request

You may try this: $request->header('referer'); Also URL::previous will give you that URL, for example: \URL::previous(); Update: You may use this to send a user back to form on failed validation: return redirect()->back(); // You may use ->withInput()->withErrors(...) as well ...

Laravel 5 Authentication

laravel,laravel-5,laravel-routing

By default the default auth routes use Route::controllers(['auth' => 'Auth\AuthController']), the Route::controller() method generates the routes based upon the functions available on the controller. You should be able to remove this line and create your own routes for them. If you look at the Illuminate/Foundation/Auth/AuthenticatesAndRegistersUsers trait you can see the...

Redirection not working in Laravel from resourceful controller for logout route

php,session,laravel,laravel-4,laravel-routing

use this: return Redirect::home();

Laravel: Missing argument 1 for AdminController::getUpdateUser()

laravel,laravel-4,laravel-routing

What you missed is putting the id actually in the route URL as a route parameter. Like this: Route::get('/admin/edit/{id}', array('uses' => '[email protected]', 'as' => 'getUpdateUser')); ...

Laravel 5 link does not work properly

php,laravel,url-routing,laravel-5,laravel-routing

There is a problem with your Laravel vhost setup in Apache. Your base url is http://localhost:8080/AutoQlik/public/ . usually it should be http://localhost:8080 instead . Because of that somewhere your URL generation has not considered this and will go to different place. If you check network tab if Firefox then you...

Laravel 5 : [Call to a member function getAction() on a non-object

laravel,laravel-5,laravel-routing

Seems obvious doesn't it? Get current route in a browser will return the currently visited route. In the terminal you do not such a request. Laravel will return null when asking what route is visited. You would have to check for the return value before calling getAction....

Ignore a route for access checking in Laravel 5 using Entrust Package

php,laravel,laravel-5,laravel-routing

You can do it like that.. (Documentation) Route::filter('admin', function() { // check the current user if (!Entrust::hasRole('admin')) { App::abort(403); } }); // only admin will have access to routes within admin/login Route::when('admin/login', 'admin'); ...

Save visitors data before returning any view with Laravel

php,laravel,initialization,laravel-routing,global-filter

Actually, that would be the most 'correct' method to place it in. I think you're not looking for a way to do something before the View is returned. You're looking for a way to do something before the response is sent. App::before() would be the correct way of doing that,...

Laravel URLs with query parameters

laravel,url-routing,laravel-routing,laravel-5

This should work: Route::get('/origin={number}', ...); ...

Manually calling controller method with parameter and still have method injection

laravel,laravel-5,ioc-container,laravel-routing

If it's only for Request, I think you could manually pass this $this->app->make('Request'), like so $controllerIntance->index($id, $this->app->make('Request')) Note that you actually don't have to inject Request, since you might as well use App::make inside of your controller. But I'm not sure how good this decision is in case of testability...

Laravel multiple optional parameter not working [duplicate]

php,laravel,routing,laravel-5,laravel-routing

Everything after the first optional parameter must be optional. If part of the route after an optional parameter is required, then the parameter becomes required. In your case, since the /xyz- portion of your route is required, and it comes after the first optional parameter, that first optional parameter becomes...

Laravel Controller Delegation

laravel,laravel-4,laravel-routing

You can define those others as controller routes as well. Just do it before Route::controller('admin') because Laravel searches the registered routes in the other you define them. Since /admin/gallery would match Route::controller('admin') as well as Route::controller('admin/gallery') latter has to be defined first: Route::controller('admin/gallery', 'AdminGalleryController'); Route::controller('admin/foo', 'AdminFooController'); Route::controller('admin', 'AdminController'); Instead of...

laravel 5 boilerplate app not working

php,laravel,laravel-4,laravel-5,laravel-routing

You should set the document root to point to your directory/public folder. In this way you will be able to access laravel directly from http://localhost...

Loading partial html template into Angular app using Laravel

angularjs,rest,laravel,laravel-routing

One way would be to reference the full path to the partials .when('/new', { controller: 'CreateCtrl' //depending on your path adjust it templateUrl: 'partials/newform' since you are just using .html not tempalte.blade.php file for template you should move it to public folder. Update: If you really dont want to move...

How to set regular expression parameter constraints for Route::group in Laravel 4?

regex,laravel,laravel-4,routes,laravel-routing

Out of the box the laravel router doesn't support this. You can use the Enhanced Router package from Jason Lewis or a fork that enables support for Laravel 4.2 Alternatively you can do it yourself. You could basically add the where condition to every route inside the group: Route::group(['prefix' =>...

Redirect subfolder to Wordpress without showing URL

php,wordpress,redirect,laravel,laravel-routing

Your best bet is to create a subdomain and map it to wordpress.com (see: https://en.support.wordpress.com/domains/map-subdomain/). Instead of having xyz.com/blog you'll have blog.xyz.com and everything will be fine....

Passing parameter to controller via Route::controller

php,laravel,laravel-4,laravel-routing

You just call your url with the user id www.mydomain.com/account/create/1 ...

How to setup Apache to run Laravel rooted from a subpath?

apache,.htaccess,laravel,laravel-routing,mod-alias

I could solve using the following in the 000-default.conf file: <Directory /var/www/example/public> DirectoryIndex index.php AcceptPathInfo on AllowOverride All Options None Order allow,deny Allow from all </Directory> And had to change the laravel .htaccess in the following way: <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On RewriteBase /dashboard # Redirect...

How to protect querystring or parameters passed to another page

php,laravel-4,laravel-routing

This is really not something you should worry about, it's a pointless waste of time. Somebody changes the URL from a 2 to a 3 and they'll see a different page... so what?! If they're allowed to see that page in the first place, i.e. if they could click around...

Query String Preservation in Laravel

laravel,laravel-5,laravel-routing

The easiest way would be to append the query string to the link URLs, using the Request facade: <a href='/teachers?{{ Request::getQueryString() }}'> Teachers <a/> and <a href='/courses?{{ Request::getQueryString() }}'> Courses <a/> ...

Redirect to Login if user not logged in Laravel

laravel,laravel-4,laravel-routing

That's already built in to laravel. See the auth filter in filters.php. Just add the before filter to your routes. Preferably use a group and wrap that around your protected routes: Route::group(array('before' => 'auth'), function(){ // your routes Route::get('/', '[email protected]'); }); Or for a single route: Route::get('/', array('before' => 'auth',...

How to create a sub- domain in laravel

php,laravel,laravel-4,laravel-routing

You can register a route group to have a certain domain: Route::group(array('domain' => 'partner.myapp.com'), function(){ Route::get('/', array( 'as' => 'partner-home', 'uses' => '[email protected]' )); }); ...

Laravel controller method calling other 'helper' methods

php,laravel,laravel-4,laravel-routing

at handleAuth(), return Redirect::intended('/'); is returning something to postLogin(). You need to return that value from the postLogin(). So, add return at postLogin(). if($auth) return $this->handleAuth(); Other Fixes at handleAuth(), also add return else return $this->handleBan($banned_info, $current_ip); ...

Redirect to Login page if ther user not logged in Laravel

laravel,laravel-5,laravel-routing

You can put as many routes in a Group as you like to Route::group(array('before' => 'auth'), function(){ Route::get('/', '[email protected]'); Route::post('store', '[email protected]'); Route::get('show', '[email protected]'); // ... }); If you really need to protect all your routes, you could add public function __construct() { $this->middleware('auth'); } To your main controller class, Http/Controllers/Controller...

Laravel Routing URLs not working except for default URI

php,.htaccess,laravel,laravel-routing,laravel-5

The problem was the subdirectories. The default installation of Laravel 5 assumes that it is served from root (in this case localhost). When I reinstalled Laravel as root everything worked correctly. Instead of setting up Virtual Hosts I just switch out symlinks from a different directory to manage the various...

Laravel withError function not working

php,forms,laravel,laravel-routing,laravel-validation

The problem was that I changed the secure option to true in session file (in config folder) and was testing it on local server without https. That is why my errors were not showing in view.

Laravel route doesn't get to the controller

php,apache,laravel,laravel-4,laravel-routing

It seems that the order is of importance. If you register admin/activities before admin it should work fine: Route::resource('admin/activities', 'activitiesController'); Route::resource('admin', 'adminController'); ...

Why in laravel do you need to specify classes in composer.json

laravel,composer-php,laravel-routing

You don't need to specify your classes in composer.json. Sure you can do that if you want but for most of the cases there is no need to do so. Let's take a look at the autoload section of Laravels default composer.json "autoload": { "classmap": [ "app/commands", "app/controllers", "app/models", "app/database/migrations",...

Should users be a resource in Laravel?

php,authentication,laravel,laravel-routing

How to determine what should be a Resource When determining what should be a resource I usually refer to my database model. You can create a DB model in DIA or an equivalent. If you have a good understanding of Entity Relationships you should have no problems determining what should...

Laravel documentation filter example

php,laravel,laravel-4,routes,laravel-routing

Input::get() fetches a parameter from the query string (GET) or form data (POST). You need to call: homestead.app/user?age=233 ...

Laravel 5 redirect after store

php,laravel,redirect,laravel-5,laravel-routing

If you want to redirect to record that was created/updated , you should change: Vehicle::create($input); into: $vehicle = Vehicle::create($input); and now: return redirect('pages/aracislemler'); into return redirect('pages/aracislemler/'.$vehicle->id); ...

Laravel 5 Function () not found

php,laravel,middleware,laravel-routing,laravel-5

you forgot the uses key : Route::get('foo/bar/{id}', ['middleware'=>'auth', 'uses'=>'[email protected]']); ...

Laravel - can I control routes by rule?

php,laravel,laravel-5,laravel-routing

Sure - just add it as a parameter. E.g. like this: Route::any('_staff_{version}', '[email protected]_staff'); public function _staff($version) { return view('_staff_'.$version); } ...

Laravel 5 making a route for a specific link

laravel,laravel-5,laravel-routing

I had a similar problem trying to send a form directly to a route (using something like /pages/vehicles/61) but it seems to be imposible (question here). If you don't have a specific route for all vehicles (/pages/vehicles doesn't show a list of vehicles) you can do something like: Route::get('pages/vehicles','[email protected]'); And...

Blank page after Redirect::to() in Laravel 4.2

laravel,laravel-4,laravel-routing

I found the problem, it was my mistake. The routs for this profile don't call direct the profile method: Route::get('/{action}/{object_id}', '[email protected]'); So, in my Controller I have (the wrong solution): public function action($action, $object_id = null){ if(method_exists($this,$action)){ $this->$action($object_id); }else{ return App::missing(); }} Correct solution: public function action($action, $object_id = null){...

Restrict route access to non-admin users

php,laravel,laravel-5,laravel-routing,laravel-middleware

You can use Middleware for this simple case. Create middleware: php artisan make:middleware AdminMiddleware namespace App\Http\Middleware; use App\Article; use Closure; use Illuminate\Contracts\Auth\Guard; class AdminMiddleware { /** * The Guard implementation. * * @var Guard */ protected $auth; /** * Create a new filter instance. * * @param Guard $auth *...

Laravel routes matching everything after prefix

laravel,laravel-4,laravel-5,laravel-routing

A little bit hacky. Routes.php: Route::group( ['prefix' => 'myprefix'], function () { Route::get('extra/{path}', ['as' => 'myprefix.one', 'uses' => '[email protected]']); Route::get('extraOTher/{path}', ['as' => 'myprefix.two', 'uses' => '[email protected]']); } ); Add a pattern. Route::pattern('path', '[a-zA-Z0-9-/]+'); Now it will catch all the routes. Controller.php: public function index($path) { echo $path; // outputs x/x/x/2/3/4/...

'Class 'App\Http\Controllers\Url' not found' — Laravel 5

php,laravel-5,laravel-routing

You should create a model with the name Url or whatever suits best inside your app folder you may also generate a url model by artisan command php artisan make:model Url or you can create one manually e.g <?php namespace App; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Query\Builder; protected $table = 'table_name' //...

Laravel 5 QueryException When I try to call Edit Function

laravel-routing

As the error states, the id column doesnt' exist in Database. If you did setup your database migrations properly you wanna run "php artisan migrate". IF you didn't. You need to set them up befor you can start using your Eloquent models....

Laravel 5 Routing Calling Wrong View

php,laravel,laravel-5,laravel-routing

Put the create (and update) route before the edit route in your routes file. Laravel 1st stumbles on the edit route and treats the create as id. You can test it by doing a dd($id) in your edit method in the controller....

Laravel prevent group parameter passing to controller

laravel,laravel-4,laravel-routing

I don't think it is possible to not pass the route group parameters to the controller function without writing your own Router classes. This is not really an answer to the question but rather another possible solution for the problem. I suggest you get the subdomain by parsing the host...

Laravel add domains to controller routes

laravel,laravel-4,routing,laravel-routing

First, all vhosts should have set the document root to the public public directory, otherwise Laravel won't bootstrap correctly. Then you can add specific routes for that domain. For example: Route::group(['domain' => 'seconddomain.com'], function(){ Route::get('/', '[email protected]'); }); Now if you go to seconddomain.com run() in AppController will be called...

Actually I am learning Laravel I need some Advance lavel resource. any body can help me [closed]

laravel,laravel-4,laravel-routing,laravel-3

I have added few resources, which will definitely help you. Laravel Docs Cribbb Tutorial, Start from page 9 and go all the way to 1. You will learn alot from here. Laracast Tutorial ...

Passing model to filter

php,laravel,laravel-routing

Route::filter('my_filter', function($route) { $book = $route->getParameter('book'); if( $book->AuthorID == Auth()::user()->AuthorID){ // ....... } }); ...

BASE URL Routing not working as intended

laravel,wampserver,laravel-5,laravel-routing

You need to configure the url parameter in config/app.php (or your appropriate environment config file). By default, this is set to http://localhost, so in your case you need to set it to http://localhost/test.com/public/. Edit It looks like the urls in the views are hard coded (for example). The fix is...

Laravel auth filter fails on production server

php,authentication,laravel,laravel-routing,laravel-filters

Ok, I found the solution. As always, RTFM... My environment was set as "testing" which is reserved for Unit Testing, and the manual nicely says: Note: Route filters are disabled when in the testing environment. To enable them, add Route::enableFilters() to your test. I changed the environment variable to "production"...

htaccess redirect to subfolder results in too many redirects

php,.htaccess,mod-rewrite,redirect,laravel-routing

To ignore folder sandy from rules below just use this rule instead: RewriteCond %{THE_REQUEST} /sendy [NC] RewriteRule ^ - [L] ...

I am trying to create a basic API in Laravel but not able to save or delete any data through it

php,laravel,laravel-5,laravel-routing

You have to send csrf token with your form data , for example if you have a blade file called add_question.blade.php contain the following form : <form action="{{action('[email protected]')}}" method="post" ><input type="text" name="question" ><input type="submit"></form> just add the following field to it : <input type="hidden" name="_token" value="{{ csrf_token() }}" /> so...

Delete record error with custom method model laravel

laravel,laravel-4,laravel-routing

Try below : Route::get('show/{$id}', function($id) { $user = new User; $user->find($id)->kill(); }); I think the param accepted has to have the same things that is passed to the closure....

How to send data/variable from one method to another in the same controller in laravel 5?

php,laravel,laravel-4,laravel-routing,laravel-5

If I did not misunderstand your question. you want the word "Role is added" to be shown in "user.role" view after the form submitted. try to put following code inside "user.role" view @if(Session::has('message')) {{ Session::get('message') }} @endif ...

Get Parent Resource Route Model on Laravel?

php,laravel-4,laravel-routing

Here's how I finally ended up doing it. Thanks to The Shift Exchange for the Request::segment(1) part! $parent_resource_class = studly_case( str_singular ( Request::segment(1) ) ); ...

How not to overload main routes with package routes?

php,laravel,laravel-4,laravel-routing

Looks like you did the right way. A problem that might happen is when adding a new route in your route.php file, you'd have to add in your route pattern as well. However, it could be solved by creating a global variable for setting it only once.

Create a Dynamic URL and Redirect to it in Laravel

php,laravel,laravel-4,laravel-routing

it is simpler than you are thinking. Route::get('{category}/{title}',['uses' => '[email protected]']); This should be the last route defined in your route list. Any other route should go upper than this one. this will match www.domain.com/music/easy-chords-in-guitar rest routes define as you want. e.g. Route::get('/',['uses' => '[email protected]']); Route::get('about',['uses' => '[email protected]']); Route::get('contact',['uses' => '[email protected]']);...

Laravel 5 500 internal error when using Request

php,laravel,laravel-5,laravel-routing

You have to pass an Request object in the index method like so: public function index(Request $request) { return $request->ip; } It's the way Laravel 5 changed. In Laravel 4 your code should work. They kind of separated it to make it more readable. This is much cleaner and more...

Why redirect show blank page in model laravel?

laravel,laravel-4,laravel-routing

Try this for redirect: 1. return Redirect::back()->withSuccess('Category successfully added.'); OR 2. return Redirect::to(URL::to('admin_posts_categories'))->withSuccess('Category successfully added.'); Add your redirect login inside Controller. Even if you want to put in model (which is not recommended) use Ardent Hook function i.e. afterSave()....

Pass a variable from blade to route and from there to another route

laravel,blade,laravel-routing

I figured it out first what i did was change Start Test to pass an array to Route <td class="center"><a href="{{ URL::route('exam_id', array('id'=>$exam->id)) }}"><i class="fa fa-arrow-circle-right"></i> Start Test</a></td> Exam Route Route::get('exam',['as' => 'exam_id', 'uses' => '[email protected]']); which in controller looks like public function create() { $exam_id = Input::get('id'); return View::make('exam.index',...

Laravel5 OldMiddleware The page isn't redirecting properly

laravel-5,laravel-routing

Put it in the $routeMiddleware.. protected $routeMiddleware = [ 'home' => 'App\Http\Middleware\OldMiddleware', ]; and in your route.. Route::get('/', ['middleware' => 'home'], function() { return "blah"; } Route::get('/home', function() { return "home"; } Then if you go to example.com/ it go to the middleware and redirect's you to /home. The The...

Laravel Custom Route Model Binding

php,laravel-5,laravel-routing

As you say, you can do {{URL::route('page',['page'=>$page->generateURLString()])}} because route('page',$page) will return the patter name. Then, my advice is, as you need some cleaner, to create a custom function extending the Route class or just declare it as a conventional function: public function page($bind){ return route('page', ['page' => $bind]); } Then...

Route using either a prefix or a domain

laravel,laravel-routing,laravel-5

This is a pretty tricky question so expect a few not so perfect workarounds in my answer... I recommend you read everything first and try it out afterwards. This answer includes several simplification steps but I wrote down whole process to help with understanding The first problem here is that...

Lumen (Laravel) routing not passing route parameter to controller

laravel-5,laravel-routing,lumen

Type hinting on a controller method will make your variable "go empty". Simply don't type hint. Your closure approach doesn't have the type hint, but your controller method does.

Getting an error in passing a variable through routes to controller in laravel

php,mysql,laravel,laravel-routing

Route should be: Route::get('author/{id}', array('as'=>'author', 'uses'=>'[email protected]_view')); ...

Laravel 5 Auth for Restful Resource Controllers to restrict resource to logged in user

authentication,laravel-5,laravel-routing

Try grouping your resources that should use a specific middleware: Route::group(['middleware' => 'auth'], function(){ Route::resource('addresses', 'AddressController'); }); Only you know how your scenario is, but another way to run filters in resources is to call to needed middlewares in the resource's constructor like: class AddressController extends Controller { public function...