public function invoiceRecord() { // get parameters from url route $parameters = $this->request->route()->parameters(); // get billing object $billing = Billing::builder()->find($parameters['id']); if (empty($billing->price_091)) { $price = (double) Preference::getValue('projectsHourPrice', 6)->value_018 * $billing->hours_091; } else { $price = $billing->price_091; } $history = History::create(['user_id_093' => $billing->user_id_091, 'user_name_093' => $billing->user_name_091, 'type_id_093' => $billing->type_id_091, 'project_id_093' => null, 'customer_id_093' => $billing->customer_id_091, 'customer_name_093' => $billing->customer_name_091, 'title_093' => $billing->title_091, 'description_093' => $billing->description_091, 'price_093' => $price, 'request_date_093' => $billing->request_date_091, 'request_date_text_093' => $billing->request_date_text_091, 'end_date_093' => $billing->end_date_091, 'end_date_text_093' => $billing->end_date_text_091, 'hours_093' => $billing->hours_091]); // create invoiced from todo_ Invoiced::create(['date_094' => date('U'), 'date_text_094' => date(config('pulsar.datePattern')), 'customer_id_094' => $billing->customer_id_091, 'customer_name_094' => $billing->customer_name_091, 'type_id_094' => $billing->type_id_091, 'project_id_094' => null, 'history_id_094' => $history->id_093, 'price_094' => $price]); // destroy billing Billing::destroy($billing->id_092); // destroy todo_ from user section Todo::destroy($billing->todo_id_092); return redirect()->route('projectsBilling', ['offset' => $parameters['offset']])->with(['msg' => 1, 'txtMsg' => trans('projects::pulsar.message_successfully_invoiced')]); }