firefly
firefly

Reputation: 906

Retrieve and edit data on page using Laravel

I cant display my data, laravel's 404 page popping. Here is my foreach codes.

    @foreach($este as $row) 
      {{$row['価格']}}
      {{$row['間取り']}}
      {{$row['販売戸数']}}
      {{$row['総戸数']}}
      {{$row['専有面積']}}
      {{$row['専有面積']}}
      {{$row['その他面積']}}
      {{$row['所在階/構造 階建']}}
      {{$row['完成時期']}}
      {{$row['住所']}}
    @endforeach  

What am I doing wrong here.

I want to edit table with css but data doesn't display.

My controller, and route is here:

public function sumos($id)
{
    $este = estates::all();
    return view('pages.sumo', ['este' => $este]);
} 

Route::get("sumo/{id}", "PagesController@sumos");

Upvotes: 1

Views: 136

Answers (5)

Excellent Lawrence
Excellent Lawrence

Reputation: 1104

Change your controller and route to the following

public function sumos()
{
  $data['este'] = estates::all();
  return view('pages.sumo', $data);
} 

Route::get("sumo", "PagesController@sumos");

then your view to

@foreach($este as $row) 
  {{$row->価格}}
  {{$row->間取り}}
  {{$row->販売戸数}}
  {{$row->総戸数}}
  {{$row->専有面積}}
  {{$row->専有面積}}
  {{$row->その他面積}}
  {{$row->所在階/構造 階建}}
  {{$row->完成時期}}
  {{$row->住所}}
@endforeach  

Upvotes: 1

Excellent Lawrence
Excellent Lawrence

Reputation: 1104

change your route to

Route::get("sumo/{id}", "PagesController@sumos");

Upvotes: 1

Egretos
Egretos

Reputation: 1175

firs you have to create a view file

How to use views in Laravel?

then just use this construction:

public function sumos()
{
    $este = estates::all();
    return view('name_of_your_view_file', compact('este');
}

Upvotes: 1

1.Actually get is for retrieve all the data from table  , 
2.After getting related data pass it on view 
public function sumos()
{
$este = estates::get();
return view("editPage" , compact('este'));
}
After View data in table using
@foreach($este as $est) //data here like html css @endforeach
add route to update data and pass it into controller
Then find related row using `
public function find($id){
$estates = estates::find($id);
//after changes 
$estates->save();
return redirect()->back();
}
`

Upvotes: 1

Mudassar Khani
Mudassar Khani

Reputation: 1479

Don't return the value from the controller . Instead send the values to the view as parameter and then use it in your view

Like

public function sumos()
{
   $este = estates::get();
   return view('viewName', ['este' => $este]);
}

And in your view

@foreach($este as $row)
  write markup for your items here. 
@endforeach

Upvotes: 1

Related Questions