public function office_data() { \DB::statement(\DB::raw('set @rownum=0')); $offices = Office::select([\DB::raw('@rownum := @rownum + 1 AS rownum'), 'id', 'code', 'name', 'abbreviation', 'date_open']); return Datatables::of($offices)->addColumn('action', function ($office) { return ' <a href="./office/detail_division/' . $office->id . '" class="btn btn-xs btn-info"><i class="glyphicon glyphicon-plus"></i> Divisi</a> <a href="./office/edit/' . $office->id . '" class="btn btn-xs btn-warning"><i class="glyphicon glyphicon-edit"></i> Edit</a> '; })->editColumn('date_open', function ($office) { return $office->date_open ? with(new Carbon($office->date_open))->format('d/m/Y') : ''; })->make(true); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $user = User::find($id); $roles = Role::lists('name', 'id'); $office_region = Office::select(\DB::raw("CONCAT(offices.code,'-',offices.name) AS full_name, id"))->lists('full_name', 'id'); $division_kprk = OfficeDivision::select(\DB::raw("CONCAT(code,'-',name) AS full_name, id"))->lists('full_name', 'id'); return view('users.edit', compact('user', 'roles', 'office_region', 'division_kprk')); }