Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8719821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:53:23+00:00 2026-06-13T06:53:23+00:00

I have just recently started working with Laravel. Great framework so far! However I

  • 0

I have just recently started working with Laravel. Great framework so far!
However I have a question.

I am using a layout template like this:
public $layout = 'layouts.private';

This is set in my Base_Controller:

public function __construct(){

    //Styles
    Asset::add('reset', 'css/reset.css');
    Asset::add('main', 'css/main.css');

    //Scripts
    Asset::add('jQuery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js');

    //Switch layout template according to the users auth credentials.
    if (Auth::check()) {
        $this -> layout = 'layouts.private';
    } else {
        $this -> layout = 'layouts.public';
    }

    parent::__construct();

}

However I get an error exception now when I try to access functions in my diffrent controllers, which should not call any view, i.e. when a user is going to login:

class Login_Controller extends Base_Controller {

public $restful = true;

public function post_index()
{

    $user = new User();
    $credentials = array('username' => Input::get('email'), 'password' => Input::get('password'));

    if (Auth::attempt($credentials))
    {

    } else {

    }

}

}

The error I get, is that I do not set the content of the different variables in my public $layout. But since no view is needed in this function, how do I tell Laravel not to include the layout in this function?

The best solution that I my self have come a cross (don’t know if this is a bad way?) is to unset($this -> layout); from function post_index()…

To sum up my question: how do I tell Laravel not to include public $layout in certain functions, where a view is not needed?

Thanks in advance,
fischer

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:53:24+00:00Added an answer on June 13, 2026 at 6:53 am

    You need to set $this->layout = null on any function you don’t want to render the view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a new programmer and I have just started recently working with applets. However,
I've just recently started developing a site for iPhone using jQTouch, and have the
I have recently just started working with Lucene (specifically, Lucene.Net) and have successfully created
Recently I have started working with Codeigniter framework in order to develop RESTFul web
I have just started playing around with using Dojo in Zend Framework and things
I recently started using Mercurial and like the way I have VCS protection for
I have recently started working with C++ classes and had just started when I
I have been using TortoiseSVN for a while now and just recently started using
I have just started C very recently and I have been asked to answer
I have recently just created Java project using Eclipse that requires 2 JAR files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.