I'm making an web app with Laravel as Api and Vue.js for the front.
I wan't to return a collection of objects but I have an error and I can't fix it.
strpos() expects parameter 1 to be string, array given
public function orderSearch (Request $request) {
$data = $request->all();
$aa = $data['search'];
$orders = Order::whereHas(['customer' => function ($query) use ($aa){
$query->where('firstname','LIKE','%' . $aa . '%')->orWhere('lastname','LIKE','%' . $aa . '%');
}])->get();
return $orders;
}
my variable $aa is working fine nad my relation between Order and Customer is fine.
Order.php
public function customer() {
return $this->belongsTo('App\Model\Customer');
}
Customer.php
public function order() {
return $this->hasMany('App\Model\Order');
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire