i want to know how get this working in laravel :
I have two tables: "orders" and "delivery_boys" .
When an order is created i want to get "id" in table "delivery_boys" that correspond to the "store_id" in the "order" table.
which looks like that in mysql SELECT `id` FROM `delivery_boys` WHERE store_id = '3'
Thanks for your help.
I use this fonction:
protected $table = 'orders';
public function addNew($data)
{
$user = AppUser::find($data['user_id']);
if(isset($data['address']) && $data['address'] > 0)
{
$address = Address::find($data['address']);
}
else
{
$address = new Address;
}
$add = new Order;
$add->user_id = $data['user_id'];
$add->store_id = $this->getStore($data['cart_no']);
$add->d_boy = $add->?????; <---- here i want to add from "delivery_boys" table the "id" that correspond to the "store_id" added just above from the "order" table ---->
$add->name = $user->name;
$add->email = $user->email;
$add->phone = $user->phone;
$add->address = $address->address;
$add->lat = $address->lat;
$add->lng = $address->lng;
$add->address = $address->address;
$add->d_charges = $this->getTotal($data['cart_no'])['d_charges'];
$add->discount = $this->getTotal($data['cart_no'])['discount'];
$add->total = $this->getTotal($data['cart_no'])['total'];
$add->payment_method = $data['payment'];
$add->payment_id = isset($data['payment_id']) ? $data['payment_id'] : 0;
$add->type = isset($data['otype']) ? $data['otype'] : 1;
$add->notes = isset($data['notes']) ? $data['notes'] : null;
$add->save();
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire