laravel 8 join query table.column_name does not work in blade or controller

Viewed 24

here is my code:

$data = Courses::select('courses.id','courses.standid', 'courses.publisher', 'courses.coverpic', 'courses.course_sts', 'standards.standtitle AS stitle', 'subjects.subtitle AS btitle')
                ->join('subjects', 'subjects.id', '=', 'courses.subjectid')
                ->join('standards', 'standards.id', '=', 'courses.standid')
                ->get();

and blade codes are:

@foreach ($data as $row)
<p>{{ $row->stitle }}</p> 
@endforeach

the query works fine when i check dd($data) under attributes, but the stitle and btitle columns never shows inside blade as {{ $row->stitle }} or {{ $row->btitle }}

what am I missing or how to collect the joining table column into the blade file?

cheers

1 Answers

Thanks for response. It was the redirect method that taking me back to history page rather then the post update status.

it was return redirect(the_view_name)->with(vars)

instead of return view(the_view_name)->with(vars)

my first experience to ask a question at stackoverflow and resolved by myself.

Related