当前位置: 首页>>代码示例>>PHP>>正文


PHP Project::rules方法代码示例

本文整理汇总了PHP中app\Project::rules方法的典型用法代码示例。如果您正苦于以下问题:PHP Project::rules方法的具体用法?PHP Project::rules怎么用?PHP Project::rules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Project的用法示例。


在下文中一共展示了Project::rules方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 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 == 5) {
         $invalid_auth = 0;
     }
     if ($invalid_auth == 1) {
         Alert::error('Anda tidak memilik akses ini')->persistent('close');
         return redirect('project/view/' . $id);
     }
     // End Check Authorization
     $validation = Validator::make($request->all(), Project::rules($id));
     // Check if it fails //
     if ($validation->fails()) {
         Alert::error('Error ! ' . $validation->errors() . ' ')->persistent("Close");
         return redirect()->back()->withInput();
     }
     $data = Project::find($id);
     if ($request->hasFile('userfile')) {
         $path = '/assets/project_logo/';
         $old_img = $data->picts;
         Storage::delete(public_path() . $path . $old_img);
         $image = $request->file('userfile');
         $filename = time() . '.' . $image->getClientOriginalExtension();
         $path = public_path('assets/project_logo/' . $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->picts = $filename;
     }
     // save category data into database //
     $data->name = $request->input('name');
     $data->save();
     Alert::success('Sukses merubah ' . $request->input('name') . ' !')->persistent("Close");
     return redirect('project/view/' . $id)->with('message', 'You just create ' . $request->input('name') . ' !');
 }
开发者ID:arisros,项目名称:drope.mployee,代码行数:47,代码来源:ProjectController.php

示例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)
 {
     $validation = Validator::make($request->all(), Project::rules($id));
     // Check if it fails //
     if ($validation->fails()) {
         Alert::error('Error ! ' . $validation->errors() . ' ')->persistent("Close");
         return redirect()->back()->withInput();
     }
     $data = Project::find($id);
     if ($request->hasFile('userfile')) {
         $path = '/assets/project_logo/';
         $old_img = $data->picts;
         Storage::delete(public_path() . $path . $old_img);
         $image = $request->file('userfile');
         $filename = time() . '.' . $image->getClientOriginalExtension();
         $path = public_path('assets/project_logo/' . $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->picts = $filename;
     }
     // save category data into database //
     $data->name = $request->input('name');
     $data->save();
     Alert::success('Sukses merubah ' . $request->input('name') . ' !')->persistent("Close");
     return redirect('project/view/' . $id)->with('message', 'You just create ' . $request->input('name') . ' !');
 }
开发者ID:arisros,项目名称:drope.mployee,代码行数:37,代码来源:ProjectController.php


注:本文中的app\Project::rules方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。