M
M
Maxim Spiridonov2014-12-02 17:20:34
Laravel
Maxim Spiridonov, 2014-12-02 17:20:34

How to display data in another template?

Actually there is a CabinetController controller, in it I am trying to display data from the database table to the Cabinet template. Since I am new to laravel, I naturally did not think of how to transfer this data to the site.blade.php template.

class CabinetController extends BaseController {
    
    public function Index(){
         if(Auth::check()){
             
             $sites = Site::selectSite();
             
             return View::make('Cabinet')->with('sites', $sites);
         }
         else{
             return View::make('cabinet.error');
         }
    }
    
}

Also, here is the Site model.
class Site extends Eloquent {
    public static $unguarded = true; 
    
    public static function selectSite(){
        $sites = Site::all();
        return $sites;
    }
    
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gladkovskiy, 2014-12-04
@SMGladkovskiy

Love the manual and look there every time you don't know how to do this or that. It's much faster, I assure you, than asking and waiting for an answer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question