jeudi 5 avril 2018

Laravel 5.6 different functions return to same view

I have different function in my laravel

 public function index()
{
    $YourData = DB::table('users')
        ->join('packages', 'users.id', '=', 'packages.user_id')
        ->select('users.*','packages.name as packageName',DB::raw('SUM(packages.entry_nr) as entries'))
        ->where('users.id', Auth::id())
        ->get();
        return view('home', compact('YourData'));

}

public function LeMiePrenotazioni(){

    $id =Auth::user()->id;
    $lesson = DB::select("
        SELECT *
        FROM lessons t
        where (t.date > now()) 
       and NOT EXISTS 
        (SELECT 1 FROM bookings b
        WHERE b.lessons_id = t.id AND b.user_id = ".$id.");
        ");
        return view('home', compact('lesson'));

}

How can I make so that I can use the two function inside my home.blade.php my route is

Route::get('/home', 'HomeController@index')->name('home');



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire