Skip to content
This repository has been archived by the owner on Feb 7, 2025. It is now read-only.

Passing variable to view #5848

Open
admiralmedia opened this issue Mar 19, 2024 · 0 comments
Open

Passing variable to view #5848

admiralmedia opened this issue Mar 19, 2024 · 0 comments

Comments

@admiralmedia
Copy link

Laravel version

9.52.16

PHP version

8.3.3-1+020240216.17+debian101.gbp87e37b

Voyager version

1.7

Database

MariaDB version 10.3.39

Description

I'm trying to pass information from 2 tables to the overriten read.blade.php(resources/views/vendor/voyager/pacient/read.blade.php) of my PacientsController but I can't figure out why I get Undefined variable $pacient error . Everything I put into the Controller is not passed to the view.
I have the following controller:
<?php namespace App\Http\Controllers; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Redirect; use Illuminate\View\View; use App\Pacients; class PacientsController extends Controller { public function read($id) { $pacient = Pacients::with('details', 'profile')->findOrFail($id); return view('pacients.read')->with($pacient); } }
I have the following route:
Route::get('/pacients/{id}', 'PacientsController@read')->name('pacients.read');

I have the following model:
<?php namespace App; use Illuminate\Database\Eloquent\Model; class Pacients extends Model { protected $table = 'pacients'; public function details() { return $this->hasOne(details::class, 'pacient_code', 'id'); } public function profile() { return $this->hasOne(Profile::class, pacient_code', 'id'); } }

I have the following view:
{{ dd($pacient); }}

Steps to reproduce

As described

Expected behavior

Show the informations

Screenshots

No response

Additional context

No response

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant