I want to fetch data from some rows in one table and save them in a different table.
public function store(Request $request)
{
$ticket= new Ticket(
array(
'ticket_id' => strtoupper(str_random(10)),
'status' => "Open",
'customername' => $request->customername,
));
$ticket->save();
return redirect()->back()->with("status", "A ticket with ID: #$ticket->ticket_id has been opened.");
}
The customername should be fetched from one table. If this condition is met the customer_idno, customer_phone and customer_id should also be fetched and saved . Here is the condition:
if($customername != ''){
$pcustm=Med_customer::where('id',$customername)->first();
$customer_id=$pcustm->id;
$customer_name=$pcustm->fullname;
$customer_idno=$pcustm->idno;
$customer_phone=$pcustm->phone;
}
How do i implement this?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/32DtPeu
via IFTTT
Aucun commentaire:
Enregistrer un commentaire