public function getApproveTransfer($id) { $date = DateTime::createFromFormat('d-m-Y', date("d-m-Y")); $dateNow = $date->format('Y-m-d'); $primary = PropTransReq::where('properties_id', $id)->pluck('id'); $hId = PropertiesUser::where('properties_id', $id)->pluck('history_id'); $oldOwner = PropertiesUser::where('properties_id', $id)->pluck('user_id'); $history = PropertiesHistory::find($hId); $property = Properties::find($id); $request = PropTransReq::find($primary); $dept = User::find($request->user_id); $par = uniqid('PAR-'); $property->update(['par' => $par]); $history->update(['details' => 'Transferred', 'enddate' => $dateNow]); $history = new PropertiesHistory(); $history->propstatus = 'Transferred'; $history->par = $par; $history->from = $oldOwner; $history->property()->associate($property); $history->user()->associate(User::find($request->user_id)); $history->save(); //------------------------- $lastid = PropertiesHistory::orderBy('id', 'desc')->first(); $approve = PropertiesUser::where('properties_id', $id)->update(array('user_id' => $request->user_id, 'history_id' => $lastid->id, 'dept_id' => $dept->department_id)); $request->delete(); //PropTransReq return Redirect::route('transfer-requests')->with('alert', 'success|Transfer Request Approved'); }
public function getViewUserProperty($id) { $prop = Properties::find($id); $histories = PropertiesHistory::where('properties_id', $id)->orderBy('created_at', 'desc')->get(); if (!$prop) { App::abort(404); } return View::make('view-property')->with('histories', $histories)->with('prop', $prop); }