/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // $data = $request->except(['_token', '_method']); $mobilefee = MobileFees::find($id); $credit = $mobilefee->employee->level->credit; if ($data['fee'] <= $credit) { $mobilefee->update($data); return back(); } else { return back()->with('message', '超出 ' . $credit . ' 额度 '); } /* $data=$request->except(['_token','_method']); $employee=Employee::find($id); $employee->update($data); return redirect()->to('employees');*/ }
/** * Execute the console command. * * @return mixed */ public function handle() { echo "Started..."; $employees = Employee::where('category_id', 2)->get(); $rules = ['employee_id' => 'required|unique_with:mobile_fees,months']; foreach ($employees as $employee) { $data['employee_id'] = $employee->id; $data['company_id'] = $employee->company_id; $data['months'] = '2015-07-01'; //$data['months']= Carbon::now()->firstOfMonth(); $data['fee'] = 0; $data['employee_number'] = $employee->number; $validator = \Validator::make($data, $rules); if ($validator->fails()) { } else { MobileFees::create($data); //Invoice::create($data); } } }
public function months($months) { Excel::create('通讯报销汇总_' . $months, function ($excel) use($months) { $companies = Company::all(); foreach ($companies as $company) { $excel->sheet('new Sheet', function ($sheet) use($company, $months) { $sheet->setAllBorders('thin'); // Set border for cells $sheet->setBorder('A1', 'thin'); // Font family $sheet->setFontFamily('Comic Sans MS'); // Set font with ->setStyle()` $sheet->setStyle(array('font' => array('name' => 'Calibri', 'size' => 11, 'bold' => false))); $sum = \App\MobileFees::where('company_id', $company->id)->where('months', $months)->with('company', 'employee')->sum('fee'); $mobilefees = \App\MobileFees::where('company_id', $company->id)->where('months', $months)->with('company', 'employee')->get(); $sheet->loadView('report.index')->with('mobilefees', $mobilefees)->with('sum', $sum)->with('company_name', $company->name); }); } })->download('xls'); }