0

my controller having the below format. how can i transfer to view in laravel

i tried ->with($inboxMessage) . The browser not even completely loaded. It's loading for a lifetime.

        $inboxMessage[] = [
        'messageId' => $message_id,
        'messageSnippet' => $snippet,
        'messageSubject' => $message_subject,
        'messageDate' => $message_date,
        'messageSender' => $message_sender
        ];
3

3 Answers 3

1

you can return your view in controller with data like below

return view('viewname', ['inboxMessage' => $inboxMessage]);

now $inboxMessage will available in view.

Sign up to request clarification or add additional context in comments.

Comments

1
return view("path to your view", compact('inboxMessage'));

Comments

1
return view("view_name",['data'=>$inboxMessage]);

and in view you can access using foreach loop or use print_r($data)

in view if you are using blade template then

@foreach($data as $val)

{{$val->messageId}}


@endforeach

or else use normal foreach loop

1 Comment

@if you are using blade template then your view name is like viewname.blade.php or else viewname.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.