Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to add folder in controller using laravel 4.x

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 109
    Comment on it

    Hello Readers,

    In my previous blog I have explained about How to implement cron job using laravel 4.x

    Now, In this Blog I will guide you How to add folder in controller using laravel 4.x

    If we want to add our own folder in controller and define controller in that folder and use these controller that is possible in laravel 4.x.

    Example : Suppose if we want to define all our admin section controller in one folder and user section controller in different folder that is possible in laravel 4.x.

    For this we have to follow few step

    For this, we will change our routes first

    Route::group(array('namespace' => 'API'), function()
    {
    Route::resource('/api/searchUsers', 'SearchApiController@searchUsers');
    
    });
    

    Here we will use namespace so we don't need to define folder name again and again.

    In every controller we have to define follow things to run our controller properly.

    use Validator;
    use Request;
    use Response;
    use User;use Userstag;use Tag;use Group;use connection; //Models
    use Illuminate\Support\Facades\DB; //To queries directly
    

    By this way we can add folder in controller.

    That's it.

    Also visit Laravel 5 Migration to know about Migrations in Laravel 5.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: