/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function Data(Request $request) { $records = Record::select(['date', 'message'])->where('affiliate_id', $request->id); return Datatables::of($records)->editColumn('date', function ($record) { return $record->getAllDate(); })->make(true); }
public static function CreatedAffiliate($affiliate) { if ($affiliate->affiliate_state_id) { $record = new Record(); if (Auth::user()) { $record->{$user_id} = Auth::user()->id; } else { $record->user_id = 1; } $record->affiliate_id = $affiliate->id; $record->date = $affiliate->change_date; $record->affiliate_state_id = $affiliate->affiliate_state_id; $record->type = NOTE_TYPE_UPDATE_AFFILIATE_STATE; $affiliate_state = AffiliateState::where('id', $affiliate->affiliate_state_id)->first(); $record->message = "Afiliado ingresó de " . $affiliate_state->name; $record->save(); } if ($affiliate->degree_id) { $record = new Record(); if (Auth::user()) { $record->{$user_id} = Auth::user()->id; } else { $record->user_id = 1; } $record->affiliate_id = $affiliate->id; $record->date = $affiliate->change_date; $record->degree_id = $affiliate->degree_id; $record->type = NOTE_TYPE_UPDATE_AFFILIATE_DEGREE; $degree = Degree::where('id', $affiliate->degree_id)->first(); $record->message = "Afiliado creado con grado de " . $degree->shortened; $record->save(); } if ($affiliate->unit_id) { $record = new Record(); if (Auth::user()) { $record->{$user_id} = Auth::user()->id; } else { $record->user_id = 1; } $record->affiliate_id = $affiliate->id; $record->date = $affiliate->change_date; $record->unit_id = $affiliate->unit_id; $record->type = NOTE_TYPE_UPDATE_AFFILIATE_UNIT; $unit = Unit::where('id', $affiliate->unit_id)->first(); $record->message = "Afiliado ingresó a la unidad de " . $unit->shortened; $record->save(); } }
return Util::getfulldate($this->fech_fin_apor); } public function getData_fech_bajatoPrint() { return Util::getfulldate($this->date_decommissioned); } public function getData_fech_ini_Reco_print() { if ($this->fech_ini_reco) { return $this->fech_ini_reco; } else { return $this->fech_ing; } } public function getData_fech_fin_Reco_print() { if ($this->fech_fin_reco) { return $this->fech_fin_reco; } else { $lastAporte = Aporte::afiliadoId($this->id)->orderBy('gest', 'desc')->first(); return $lastAporte->gest; } } } Affiliate::created(function ($affiliate) { Record::CreatedAffiliate($affiliate); }); Affiliate::updating(function ($affiliate) { Activity::updateAffiliate($affiliate); Record::UpdatingAffiliate($affiliate); });