laravel-routing

Laravel Roles and authentication to routes

两盒软妹~` 提交于 2019-12-24 03:05:37
问题 I am looking to archive the the following Userlogs in -> Assigned a privilege from the DB -> They can only see allowed routes only So far i have been able to reach here: $user = Usercredential::where('username','=',Auth::user()->username)->get(); foreach ($user as $u ) { $status = $u->userstatus; $userPriv = $u->userpriviledge; if ($status == 0){ Session::put('user_priv',$userPriv); } else{ return Redirect::to_route('home')->with('message','Inactive users cannot login'); } Which checks the

Call to a member function where() on a non-object Laravel 4.2

元气小坏坏 提交于 2019-12-23 15:49:43
问题 I am attempting to use and id that being passed into the URL to edit the query but when attempting to run the code I get an error of: Call to a member function where() on a non-object Controller class HomeController extends BaseController { public function showWelcome() { $id = intval($_GET['wab_id']); $results = DB::Table('films')->get()->where('wab_id','=', $id); print_r($results); while ($row=mysql_fetch_array($results)) { $url = $row['url']; } return View::make('hello')->with('row', $url)

Alias for a route with a fixed parameter value

半城伤御伤魂 提交于 2019-12-23 12:53:07
问题 I have this route: Route::get('/MyModel/{id}', 'MyController@show'); The method show() accepts a parameter called id and I want to setup an alias for /MyModel/1 so it's accesible from /MyCustomURL . I already tried a few combinations, like: Route::get('/MyCustomURL', ['uses' => 'MyController@show', 'id' => 1]); But I keep getting missing required argument error for method show() . Is there a clean way to achieve this in Laravel? 回答1: In Laravel 5.4 (or maybe earlier) you can use defaults

Laravel 4 remove /index on default getIndex controller function

心已入冬 提交于 2019-12-23 12:16:54
问题 Is it possible to remove /index on default getIndex restful controller function? Defined route for controller: Route::controller('registration', 'RegisterController', array( 'getIndex' => 'getRegister' )); Controller: class RegisterController extends UserController { public function getIndex() { // Show the register page return View::make('register'); } } For example, in my login.blade.php i have: {{ HTML::link(URL::route('getRegister'), 'New User?', array('title' => 'Novi korisnik?', 'class'

What does “as” keyword mean in Laravel routing?

不羁的心 提交于 2019-12-23 07:52:12
问题 As I understand from the Laravel documentation, it's used for redirection, but maybe I'm wrong. I wrote Route::get('user/profile', ['as' => 'profile', function () { echo 'some_text'; }]); then I was expecting my URL to redirect from https://base_url/public/index.php/user/profile to https://base_url/public/index.php/profile but it doesn't happen. Overall, I want to know, what the difference is if I used Route::get('user/profile', function () { echo 'some_text'; }); instead of the above routing

Pass many optional parameters to route in Laravel 4

被刻印的时光 ゝ 提交于 2019-12-22 05:46:11
问题 I need to built URLs like this: http://www.example.com/param1/param2/param3/.../paramN in a search page, user searchs by any possible options so making a URL like it in Laravel would be like this: Route::get('{param1?}/{param2?}/{param3?}/.../{paramN?}', array( ... ) ); Is there any other way? Or maybe pass / as a part of parameter to have this: low_range-1000/high_range-5000/weight-2/height-4/red/ so above line become just one parameter to route. any help? 回答1: well, I found the solution.

Add url extensions to Laravel routes

删除回忆录丶 提交于 2019-12-22 05:43:14
问题 Is it possible to add an extension to laravel routes like so? http://www.mywebsite.com/members/login.html and another page with a different extension http://www.mywebsite.com/contactus.htm I am transitioning an old website into laravel but the owner doesn't want to change the URL for SEO purposes. 回答1: Yes, this is certainly possible and very straightforward to do with Laravel. routes.php: Route::get('members/login.html', function() { return View::make('members.login'); } ); Then you need to

Laravel 4: Nest view inside layout with data

回眸只為那壹抹淺笑 提交于 2019-12-21 21:36:43
问题 I'm writing a simple app which only relies on a few routes and views. I've setup an overall layout and successfully nested a template using the following. routes.php View::name('layouts.master', 'master'); $layout = View::of('master'); Route::get('/users', function() use ($layout) { $users = Users::all() return $layout->nest('content','list-template'); }); master.blade.php <h1>Template</h1> <?=$content?> list-template.php foreach($users as $user) { echo $user->title; } How do I pass the query

Laravel 5.1 Wildcard Route

对着背影说爱祢 提交于 2019-12-21 15:15:24
问题 I'm creating a CMS that allows the user to define categories. Categories can either have additional categories under it or pages. How can I create a route in Laravel that will support a potentially unlimited number of URI segments? I've tried the following.... Route::get('/resources/{section}', ['as' => 'show', 'uses' => 'MasterController@show']); I also tried making the route optional... Route::get('/resources/{section?}', ['as' => 'show', 'uses' => 'MasterController@show']); Keep in mind,

Prevent Sessions For Routes in Laravel (Custom on-demand session handling)

久未见 提交于 2019-12-20 18:49:11
问题 I am building APIs for my Android app using laravel and default session driver set to REDIS. I found a good article here http://dor.ky/laravel-prevent-sessions-for-routes-via-a-filter/ which sort of serves the purpose. However when ever I hit the url it also hits the redis and generates the key which is empty. Now I want avoid creating empty session keys in redis. Ideally it should not hit the redis How can I do that? Can we customise sessios in a way so that sessions are generated only for