samedi 10 décembre 2016

Laravel - Load common header and footer to view

I am new to laravel and I am trying to load header, footer and the view file from controller in a common template and display the data from controller in the view file. But I am get error View ['admin.dashboard'] not found.

The dashboard file is present in admin folder inside views

controller

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class common extends Controller
{

   public function login()
   {
        $data['title'] = 'Dashboard';
        $data['template'] = 'admin/dashboard';
        return view('common_template', compact('data'));

   }
}

common_template.blade View

<?php echo View::make('includes/header'); ?>

<?php echo $template = "'".$data['template']."'"; 
echo View::make($template); ?> 
<?php echo View::make('includes/footer'); ?>

When I add 'admin/dashboard' instead of $data['template'] directly in $template it loads the dashboard file whereas it doesnt load when i pass it as string from controller.

dashboard.blade view

<p><?php echo $data['title']; ?></p> //printing the data from the controller

Kindly help me get through this. Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire