本文整理汇总了PHP中app\Employee::rules方法的典型用法代码示例。如果您正苦于以下问题:PHP Employee::rules方法的具体用法?PHP Employee::rules怎么用?PHP Employee::rules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Employee
的用法示例。
在下文中一共展示了Employee::rules方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$validation = Validator::make($request->all(), Employee::rules($id), ['name' => 'required|min:4|max:55', 'tempat_lahir' => 'required|min:4|max:55', 'tanggal_lahir' => 'required', 'kelamin' => 'required', 'agama' => 'required', 'status_nikah' => 'required', 'nohp' => 'required', 'alamat' => 'required|min:10|max:555', 'pt' => 'required', 'id_provinces' => 'required']);
// Check if it fails //
if ($validation->fails()) {
return redirect()->back()->withInput()->with('errors', $validation->errors());
}
$jabatan = $request->input('jabatan');
if ($jabatan > 0) {
$internal = 1;
} else {
$internal = 0;
}
// tag cities
$data = Employee::find($id);
$fr = serialize(Input::get('cities'));
if ($request->hasFile('userfile')) {
$path = '/assets/employee/';
$old_img = $data->pict;
Storage::delete(public_path() . $path . $old_img);
$image = $request->file('userfile');
$filename = time() . '.' . $image->getClientOriginalExtension();
$path = public_path('assets/employee/' . $filename);
$img = Image::make($image->getRealPath());
// resize the image to a width of 300 and constrain aspect ratio (auto height)
$img->resize(300, null, function ($constraint) {
$constraint->aspectRatio();
});
$img->save($path);
$data->pict = $filename;
}
// save category data into database //
$data->name = $request->input('name');
$data->tempat_lahir = $request->input('tempat_lahir');
$data->tanggal_lahir = $request->input('tanggal_lahir');
$data->kelamin = $request->input('kelamin');
$data->agama = $request->input('agama');
$data->status_nikah = $request->input('status_nikah');
$data->no_ktp = $request->input('no_ktp');
$data->berat_badan = $request->input('berat_badan');
$data->tinggi_badan = $request->input('tinggi_badan');
$data->nohp = $request->input('nohp');
$data->nohp2 = $request->input('nohp2');
$data->alamat = $request->input('alamat');
$data->id_jabatans = $jabatan;
$data->internal = $internal;
$data->pendidikan = $request->input('pt');
$data->des_pendidikan = $request->input('ptd');
$data->id_provinces = $request->input('id_provinces');
$data->id_cities = $fr;
$data->grade = $request->input('grade');
$data->save();
Alert::success('Sukses input ' . $request->input('name') . ' !')->persistent("Close");
return redirect('data/list')->with('message', 'You just create ' . $request->input('name') . ' !');
}
示例2: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
// Start Check Authorization
/**
* 1. FullAccess - 1
* 2. HRD - 3
* 3. Creator - 5
* 4. Handler - 7
*/
$invalid_auth = 1;
$authRole = Auth::user()->UserRoles->role;
if ($authRole == 7 or $authRole == 1 or $authRole == 3) {
$invalid_auth = 0;
}
if ($invalid_auth == 1) {
Alert::error('Anda tidak memilik akses ini')->persistent('close');
return redirect('data/list');
}
// End Check Authorization
$validation = Validator::make($request->all(), Employee::rules($id), ['name' => 'required|min:4|max:55', 'tempat_lahir' => 'required|min:4|max:55', 'tanggal_lahir' => 'required', 'kelamin' => 'required', 'agama' => 'required', 'status_nikah' => 'required', 'nohp' => 'required', 'alamat' => 'required|min:10|max:555', 'pt' => 'required', 'id_provinces' => 'required']);
$fr = serialize(Input::get('cities'));
if (!Input::get('cities')) {
$fr = "";
}
// Check if it fails //
if ($validation->fails()) {
return redirect()->back()->withInput()->with('errors', $validation->errors());
}
$jabatan = $request->input('jabatan');
if ($jabatan > 0) {
$internal = 1;
} else {
$internal = 0;
}
// tag cities
$data = Employee::find($id);
if ($request->hasFile('userfile')) {
$path = '/assets/employee/';
$old_img = $data->pict;
$image = $request->file('userfile');
$filename = time() . '.' . $image->getClientOriginalExtension();
$path = public_path('assets/employee/' . $filename);
$img = Image::make($image->getRealPath());
// resize the image to a width of 300 and constrain aspect ratio (auto height)
$img->resize(300, null, function ($constraint) {
$constraint->aspectRatio();
});
$img->save($path);
$data->pict = $filename;
}
if ($request->hasFile('userfile2')) {
$path2 = '/assets/employee/';
$old_img2 = $data->pict2;
$image2 = $request->file('userfile2');
$filename2 = time() . '_2.' . $image2->getClientOriginalExtension();
$path2 = public_path('assets/employee/' . $filename2);
$img2 = Image::make($image2->getRealPath());
// resize the image to a width of 300 and constrain aspect ratio (auto height)
$img2->resize(300, null, function ($constraint) {
$constraint->aspectRatio();
});
$img2->save($path2);
$data->pict2 = $filename2;
}
// save category data into database //
$data->name = $request->input('name');
// Revisi Data Juni 2016
$data->namaIbuKandung = $request->input('namaIbuKandung');
$data->npwp = $request->input('npwp');
$data->kk = $request->input('kk');
$data->bpjs = $request->input('bpjs');
$data->bank = $request->input('bank');
$data->rek = $request->input('rek');
$data->email = $request->input('email');
$data->anak = $request->input('jumlahAnak');
$data->kodepos = $request->input('kodepos');
$data->tempat_lahir = $request->input('tempat_lahir');
$data->tanggal_lahir = $request->input('tanggal_lahir');
$data->kelamin = $request->input('kelamin');
$data->agama = $request->input('agama');
$data->status_nikah = $request->input('status_nikah');
$data->no_ktp = $request->input('no_ktp');
$data->berat_badan = $request->input('berat_badan');
$data->tinggi_badan = $request->input('tinggi_badan');
$data->nohp = $request->input('nohp');
$data->nohp2 = $request->input('nohp2');
$data->alamat = $request->input('alamat');
$data->id_jabatans = $jabatan;
$data->internal = $internal;
$data->pendidikan = $request->input('pt');
$data->des_pendidikan = $request->input('ptd');
$data->id_provinces = $request->input('id_provinces');
$data->id_cities = $fr;
//.........这里部分代码省略.........