I'm newbie and would like some help, I have a controller
that performs a query.
Controller
$user = $this->user->find('1');
view('index', compact('user'));
View
@forelse ($user as $u)
<h1>{{ $u->name }}</h1>
@endforeach
In View
would need to put some extra field example: active, but would not like to tinker in the database just put a field and access in
{{ $u->ativo }}
I hope it was clear.
To clarify further ...
user was just an example, instead of passing another object to View
in Controller
would like to change that object and include items in it, let's say I pass user
and post
instead to make a new foreach
.
Instead:
view('index', compact('user'),compact('post'));
Like
view('index', compact('user'));
Note: user or another example name only.
Instead:
View
<h1>{{ $user->name }}</h1>
@forelse ($post as $u)
<h1>{{ $u->name }}</h1>
@endforeach
this:
@forelse ($user as $u)
<h1>{{ $u->name }}</h1>
<h1>{{ $u->Postname }}</h1>
@endforeach
I hope the explanation is better.