Where to apply custom middleware for authentication Laravel 5.2

In my project two type of users, Admin and Normal User. They are identified by the field isAdmin in users table. User can edit their profile by using the function below

public function userEditprofile(){     $user_detail = userDetail::find(Auth::user()->id);     $user_detail->address = Input::get('address');     .......     $user_detail->save()     return Redirect::route('showUserProfile'); } 

and route is

Route::group(['middleware' => 'my_profile'], function() {     Route::get('/editprofile', array('uses' => '[email protected]', 'as' => 'userEditprofile')); }); 

Admin can also edit any users profile by using

public function adminEditUserprofile($user_id){         $user_detail = userDetail::find($user_id);         $user_detail->address = Input::get('address');         .......         $user_detail->save()         return Redirect::route('showUserProfile', $user_id);     } 

In both cases action is same but in first method there is no parameter is required. But in the case of admin , a parameter is required. Can I optimize the code by using any other way? I am a self learned programmer. I am not much aware of efficient programming methods.Can anyone reply?

Replay

Category: laravel Time: 2016-07-30 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.233 (s). 12 q(s)