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');
}
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2WLZD1D
via IFTTT
Aucun commentaire:
Enregistrer un commentaire