blastme
blastme

Reputation: 429

Error: Method with does not exist laravel

I keep on getting this error method with does not exist and I have no idea how to fix it. I saw people who posted similar question like this and it usually the fault of all() but I am not using it. Can anyone help?

controller:

public function getPerson(){
     return view('show');
}
public function getInfo($id) {
      $user_info1 = user_info1::where('user_id',$id)->get();
      $data['data'] = DB::table('personal_infos')::with('userinfo1s')->get()->sortByDesc('upload_time'); //error come from this line
      return view('test', compact('user_info1','data'));
}

Upvotes: 0

Views: 1091

Answers (2)

Summer Su
Summer Su

Reputation: 289

the function sortByDesc must before the function get();

Upvotes: 1

ZeroOne
ZeroOne

Reputation: 9117

sortByDesc is in collection laravel.. use orderby instead

$data['data'] = PersonalInfos::with('userinfo1s')->orderby('upload_time')->get();

Upvotes: 0

Related Questions