/** * Add all the cost for the booking * Save belongsTo relationship with Booking model. * * @param $request [get user input] * @param $id [get booking id] */ public function addBookingDetail($request, $id) { $booking = $this->booking->getById($id); $givenInput = $request->all(); $data = $this->model->create($givenInput); $data->booking()->save($booking); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ['short_description' => 'required|max:255']); Cost::create(['date_mgr' => $request->date_mgr, 'date_acc' => $request->date_acc, 'short_description' => $request->short_description, 'description' => $request->description, 'value' => $request->value, 'fiscal_document_id' => $request->fiscal_document_id, 'supplier_id' => $request->supplier_id, 'currency_id' => $request->currency_id, 'company_id' => $request->company_id, 'marketing_channel_id' => $request->marketing_channel_id, 'category_id' => $request->category_id, 'cost_status_id' => $request->cost_status_id]); return redirect('/cost'); }