Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant