Beispiel #1
0
 public function editSave(Request $request)
 {
     $allowed = array('png', 'jpg', 'gif');
     $hasil = false;
     $image = 'holder.js/180x180';
     $results = new \StdClass();
     $validator = \Validator::make($request->all(), ['nama' => 'required', 'mode' => 'required']);
     $destination = ParentFrontpage::UPLOAD_PATH;
     $result = '';
     if ($validator->passes()) {
         if ($request->has('id') && $request->input('id') != 'xxx') {
             $result = ParentFrontpage::find($request->input('id'));
             $results->info = 'menu frontpage update';
             $results->status = 1;
             $permission = Permission::where('name', $result->nama)->get()->first();
         } else {
             $result = new ParentFrontpage();
             $results->info = 'menu frontpage create';
             $results->status = 1;
             $permission = new Permission();
         }
         $results->message = 'Proses Pengubahan Menu Sukses!';
         $result->nama = $request->input('nama');
         $result->mode = $request->input('mode');
         $result->redirect = $request->input('redirect');
         $result->public_key = $request->input('puKey');
         $result->private_key = $request->input('prKey');
         $result->query = $request->input('query');
         $result->db_host = $request->input('dbhost');
         $result->db_user = $request->input('dbuser');
         $result->db_pass = $request->input('dbpass');
         if ($request->hasFile('image')) {
             if ($request->file('image')->isValid()) {
                 $filename = date('YmdHis') . str_pad(rand(0, 1000), 4, 0, STR_PAD_LEFT) . '.' . $request->file('image')->guessExtension();
                 $img = \Image::make($request->file('image'))->fit(180, 180)->save($destination . $filename);
                 $result->image = $filename;
             }
         }
         $result->save();
         $permission->name = $request->input('nama');
         $permission->display_name = 'Dapat Mengakses ' . $request->input('nama');
         $permission->description = 'Dapat Mengakses ' . $request->input('nama');
         $permission->access = 'access';
         $permission->action = $result->id;
         $permission->type = 'app';
         $permission->save();
         $results->info = 'permission create';
     } else {
         $results->info = 'menu frontpage';
         $results->status = 0;
         $results->message = 'Proses Pengubahan Menu Gagal!';
     }
     $results->result = $result;
     return response()->json($results);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function editSave(Request $request)
 {
     $allowed = array('png', 'jpg', 'gif');
     $hasil = false;
     $image = 'holder.js/180x180';
     $results = new \StdClass();
     $validator = \Validator::make($request->all(), ['nama' => 'required', 'mode' => 'required']);
     $destination = ParentFrontpage::UPLOAD_PATH;
     $result = '';
     if ($validator->passes()) {
         if ($request->has('id') && $request->input('id') != 'xxx') {
             $result = ParentFrontpage::find($request->input('id'));
             $results->info = 'menu frontpage update';
             $results->status = 1;
         } else {
             $result = new ParentFrontpage();
             $results->info = 'menu frontpage create';
             $results->status = 1;
         }
         $results->message = 'Proses Pengubahan Menu Sukses!';
         $result->nama = $request->input('nama');
         $result->mode = $request->input('mode');
         $result->redirect = $request->input('redirect');
         $result->publicKey = $request->input('puKey');
         $result->privateKey = $request->input('prKey');
         if ($request->hasFile('image')) {
             if ($request->file('image')->isValid()) {
                 $filename = date('YmdHis') . str_pad(rand(0, 1000), 4, 0, STR_PAD_LEFT) . '.' . $request->file('image')->guessExtension();
                 $img = \Image::make($request->file('image'))->fit(180, 180)->save($destination . $filename);
                 $result->image = $filename;
             }
         }
         $result->save();
     } else {
         $results->info = 'menu frontpage';
         $results->status = 0;
         $results->message = 'Proses Pengubahan Menu Gagal!';
     }
     $results->result = $result;
     return response()->json($results);
 }