D
D
dargezrogue2019-04-02 19:21:10
Laravel
dargezrogue, 2019-04-02 19:21:10

How to pass data to laravel view?

there is a link that, when clicked, redirects to the adminpanel/home
route for it:

Route::get('/adminpanel/home', '[email protected]');

The controller that handles the transition:
namespace App\Http\Controllers\admin;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Request;

class lotscontroller extends Controller
{
    public function index(Request $request){
     if ($request->has('home')){
         $lots = DB::table('lots')->get();
         return view('admin.home', compact('lots'));
     }
     else{
         return view('adminPanel');
     }
    }
}

View for sections:
@extends('adminPanel')
@section('content')
    @foreach($lots as $lot)
        {{$lot->id}}
    @endforeach
@endsection

And the view where the content section is passed
@if(isset($_GET['home']))
    @yield('content')
@endif

Data is not displayed in the last view, I don’t understand why, help me figure it out, please!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shamanov, 2019-04-03
@SilenceOfWinter

$_GET was not passed to the template, $request->has('home') checks for more than just GET. but also POST

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question