0

Its not duplicate question. Sorry for such type of starting.

$sum = DB::table('tasklists')->sum('list_weight')->where('task_id','10');

it show me Call to a member function where() on float. I am trying to find out the reason ......

1 Answers1

0

Use sum after the where as you need to condition first and take output later.

What happens is when you call a function on DB which generates a output or query result, The facade runs the query and gets you the output.

So, in your case when you call sum the query prepared before sum is get executed and sum returns the sum of results i.e. float.

Now, you are trying to access where method on a float(which is output of the sum) not on the query itself.

That is why you are getting the error.

Parantap Parashar
  • 1,930
  • 1
  • 14
  • 22
  • I am facing another problem on URL::previous() . When I use it in multiple pages it makes loop . My expectation is to make back button. can u tell me how can I do that? – Mujahidur Rahman Mithun IUB Dec 18 '17 at 14:04
  • Yes it would definately behave like this. If you just want to replicate the browsers back behaviour just use javascript's `window.history.back()`. [Onclick javascript to make browser go back to previous page?](https://stackoverflow.com/questions/8067510/onclick-javascript-to-make-browser-go-back-to-previous-page) – Parantap Parashar Dec 18 '17 at 14:08
  • Thanks again. but i want to refresh page when I go back – Mujahidur Rahman Mithun IUB Dec 18 '17 at 14:14