I have created method in model as:
class bill extends Model
{
public static function getTable() {
$tables = Bill::where('order_type', '0')
->where('table_no','<>','')
->groupBy('table_no')
->get();
return $tables;
} }
and in controller i am accessing this method as
public function bill()
{
$data = Bill::getTable();
return view('bill.bills');
}
It is giving error as Cannot make non static method Illuminate\Database\Eloquent\Model::getTable() static in class App\bill
at line no 17. I am not getting what is wrong?
Well the problem is that the Eloquent Model
abstract class which is a parent class of your bill
(you shouldn't break convetion and use bill
and Bill
in another place) has non-static method: getTable
so you cannot override it in a static way. PLease change the name of this method.
You may have done extends in Laravel's built-in class. That's about it.
class Collection extends \App\Models\FbAccount implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerable
Here I am inheriting from \App\Models\FbAccount
, because of this, this error occurs. Remove inheritance.
Thank you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.