public function get_page()
 {
     $id = Request::segment(3);
     $information = Information::find($id);
     $response_array = array();
     if ($information) {
         $response_array['success'] = true;
         $response_array['title'] = $information->title;
         $response_array['content'] = $information->content;
         $response_array['icon'] = $information->icon;
     } else {
         $response_array['success'] = false;
     }
     $response_code = 200;
     $response = Response::json($response_array, $response_code);
     return $response;
 }
예제 #2
0
 public function update_info_page()
 {
     $id = Input::get('id');
     $title = Input::get('title');
     $description = Input::get('description');
     if ($id == 0) {
         $information = new Information();
     } else {
         $information = Information::find($id);
     }
     if (Input::hasFile('icon')) {
         // Upload File
         $file_name = time();
         $file_name .= rand();
         $ext = Input::file('icon')->getClientOriginalExtension();
         Input::file('icon')->move(public_path() . "/uploads", $file_name . "." . $ext);
         $local_url = $file_name . "." . $ext;
         // Upload to S3
         if (Config::get('app.s3_bucket') != "") {
             $s3 = App::make('aws')->get('s3');
             $pic = $s3->putObject(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'SourceFile' => public_path() . "/uploads/" . $local_url));
             $s3->putObjectAcl(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'ACL' => 'public-read'));
             $s3_url = $s3->getObjectUrl(Config::get('app.s3_bucket'), $file_name);
         } else {
             $s3_url = asset_url() . '/uploads/' . $local_url;
         }
         if (isset($information->icon)) {
             if ($information->icon != "") {
                 $icon = $information->icon;
                 unlink_image($icon);
             }
         }
         $information->icon = $s3_url;
     }
     $information->title = $title;
     $information->content = $description;
     $information->save();
     $title_new = str_replace(' ', '_', $title);
     $file = base_path() . "/app/views/website/" . $title . ".blade.php";
     if (!file_exists($file)) {
         $fp = fopen($file, "w");
         $body = generate_generic_page_layout($description);
         fwrite($fp, $body);
         fclose($fp);
     }
     return Redirect::to("/admin/information/edit/{$information->id}?success=1");
 }
예제 #3
0
 public function editInformation($id, $value)
 {
     if ($information = Information::find($id)) {
         $information->value = str_replace('-', '/', $value);
         if ($information->save()) {
             return Redirect::back()->with('flash_message', 'Information was successfully updated');
         } else {
             return Redirect::back()->withErrors('Error. Information not saved.');
         }
     }
     return Redirect::back()->withErrors('Information not found!');
 }
예제 #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Request $request)
 {
     $user = Information::find($request->input('id'));
     $user->delete();
     return "User record successfully deleted #" . $request->input('id');
 }
 public function update_info_page()
 {
     $id = Input::get('id');
     $title = Input::get('title');
     $description = Input::get('description');
     if ($id == 0) {
         $information = new Information();
     } else {
         $information = Information::find($id);
     }
     if (Input::hasFile('icon')) {
         // Upload File
         $file_name = time();
         $file_name .= rand();
         $ext = Input::file('icon')->getClientOriginalExtension();
         Input::file('icon')->move(public_path() . "/uploads", $file_name . "." . $ext);
         $local_url = $file_name . "." . $ext;
         // Upload to S3
         if (Config::get('app.s3_bucket') != "") {
             $s3 = App::make('aws')->get('s3');
             $pic = $s3->putObject(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'SourceFile' => public_path() . "/uploads/" . $local_url));
             $s3->putObjectAcl(array('Bucket' => Config::get('app.s3_bucket'), 'Key' => $file_name, 'ACL' => 'public-read'));
             $s3_url = $s3->getObjectUrl(Config::get('app.s3_bucket'), $file_name);
         } else {
             $s3_url = asset_url() . '/uploads/' . $local_url;
         }
         $information->icon = $s3_url;
     }
     $information->title = $title;
     $information->content = $description;
     $information->save();
     return Redirect::to("/admin/information/edit/{$information->id}?success=1");
 }