예제 #1
0
 public function doPrint(Request $request)
 {
     $print = Product::findOrFail(config('proto.printproduct'));
     if ($print->stock <= 0) {
         $request->session()->flash('flash_message', 'You cannot print at this time. Either the paper or the toner are empty or something is broken.');
         return Redirect::back();
     }
     $upload = $request->file('file');
     if ($upload->getMimeType() != "application/pdf") {
         $request->session()->flash('flash_message', 'You uploaded an invalid PDF file.');
         return Redirect::back();
     }
     $file = new StorageEntry();
     $file->createFromFile($upload);
     $file->is_print_file = true;
     $file->save();
     $copies = $request->input('copies');
     if ($copies < 1) {
         $request->session()->flash('flash_message', "You cannot print nothing.");
         return Redirect::back();
     }
     $result = FileController::requestPrint('document', $file->generatePath(), $copies);
     if ($result === false) {
         $request->session()->flash('flash_message', "Something went wrong trying to reach the printer service.");
         return Redirect::back();
     } elseif ($result != "OK") {
         $request->session()->flash('flash_message', "The printer server responded something unexpected: " . $result);
         return Redirect::back();
     }
     $pdf = file_get_contents(storage_path('app/' . $file->filename));
     $pages = preg_match_all("/\\/Page\\W/", $pdf, $dummy);
     $orderline = OrderLine::create(['user_id' => Auth::user()->id, 'product_id' => $print->id, 'original_unit_price' => $print->price, 'units' => $copies * $pages, 'total_price' => $request->has('free') && Auth::user()->can('board') ? 0 : $copies * $pages * $print->price]);
     $request->session()->flash('flash_message', 'Printed ' . $file->original_filename . ' (' . $pages . ' pages) ' . $copies . ' times. You can collect your printed document in the Protopolis!');
     return Redirect::back();
 }
예제 #2
0
 public function image($id, Request $request)
 {
     $committee = Committee::find($id);
     $image = $request->file('image');
     if ($image) {
         $file = new StorageEntry();
         $file->createFromFile($image);
         $committee->image()->associate($file);
         $committee->save();
     } else {
         $committee->image()->dissociate();
         $committee->save();
     }
     return Redirect::route('committee::show', ['id' => $id]);
 }
예제 #3
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $user = User::findOrFail($id);
     $image = $request->file('image');
     if ($image) {
         $file = new StorageEntry();
         $file->createFromFile($image);
         $user->photo()->associate($file);
         $user->save();
     } else {
         Session::flash("flash_message", "You forget an image to upload, silly!");
         return Redirect::back();
     }
     Session::flash("flash_message", "Your profile picture has been updated!");
     return Redirect::back();
 }
예제 #4
0
 public function getImage($id, $hash, Request $request)
 {
     $entry = StorageEntry::findOrFail($id);
     if ($hash != $entry->hash) {
         abort(404);
     }
     $response = new Response($this->makeImage($entry, $request->has('w') ? $request->input('w') : null, $request->has('h') ? $request->input('h') : null), 200);
     $response->header('Content-Type', $entry->mime);
     $response->header('Cache-Control', 'max-age=86400');
     return $response;
 }
예제 #5
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $company = Company::findOrFail($id);
     $company->name = $request->name;
     $company->url = $request->url;
     $company->excerpt = $request->excerpt;
     $company->description = $request->description;
     $company->on_carreer_page = $request->has('on_carreer_page');
     $company->in_logo_bar = $request->has('in_logo_bar');
     $company->membercard_excerpt = $request->membercard_excerpt;
     $company->membercard_long = $request->membercard_long;
     $company->on_membercard = $request->has('membercard_excerpt');
     if ($request->file('image')) {
         $file = new StorageEntry();
         $file->createFromFile($request->file('image'));
         $company->image()->associate($file);
     }
     $company->save();
     Session::flash("flash_message", "Your company '" . $company->name . "' has been edited.");
     return Redirect::route('companies::admin');
 }
예제 #6
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $event = Event::findOrFail($id);
     $event->title = $request->title;
     $event->start = strtotime($request->start);
     $event->end = strtotime($request->end);
     $event->location = $request->location;
     $event->secret = $request->secret;
     $event->description = $request->description;
     $event->summary = $request->summary;
     if ($request->file('image')) {
         $file = new StorageEntry();
         $file->createFromFile($request->file('image'));
         $event->image()->associate($file);
     }
     $committee = Committee::find($request->input('committee'));
     $event->committee()->associate($committee);
     $event->save();
     Session::flash("flash_message", "Your event '" . $event->title . "' has been saved.");
     return Redirect::route('event::edit', ['id' => $event->id]);
 }
예제 #7
0
 /**
  * Update the specified campaign.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $narrowcasting = NarrowcastingItem::find($id);
     if (!$narrowcasting) {
         abort(404);
     }
     $narrowcasting->name = $request->name;
     $narrowcasting->campaign_start = strtotime($request->campaign_start);
     $narrowcasting->campaign_end = strtotime($request->campaign_end);
     $narrowcasting->slide_duration = $request->slide_duration;
     if ($request->file('image')) {
         $file = new StorageEntry();
         $file->createFromFile($request->file('image'));
         $narrowcasting->image()->associate($file);
     }
     if ($request->has('youtube_id')) {
         $video = Youtube::getVideoInfo($request->get('youtube_id'));
         if (!$video) {
             Session::flash("flash_message", "This is an invalid video ID!");
             return Redirect::back();
         }
         $narrowcasting->youtube_id = $video->id;
     } else {
         $narrowcasting->youtube_id = null;
     }
     $narrowcasting->save();
     Session::flash("flash_message", "Your campaign '" . $narrowcasting->name . "' has been saved.");
     return Redirect::route('narrowcasting::list');
 }
예제 #8
0
 public function deleteAttachment(Request $request, $id, $file_id)
 {
     $email = Email::findOrFail($id);
     if ($email->sent || $email->ready) {
         $request->session()->flash('flash_message', 'You can currently not edit this e-mail. Please make sure it is in draft mode.');
         return Redirect::route('email::admin');
     }
     $file = StorageEntry::findOrFail($file_id);
     $email->attachments()->detach($file);
     $email->save();
     $request->session()->flash('flash_message', 'Attachment deleted.');
     return Redirect::route('email::edit', ['id' => $email->id]);
 }
예제 #9
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $product = Product::findOrFail($id);
     $product->fill($request->except('image', 'product_categories'));
     $product->is_visible = $request->has('is_visible');
     $product->is_alcoholic = $request->has('is_alcoholic');
     $product->is_visible_when_no_stock = $request->has('is_visible_when_no_stock');
     if ($request->file('image')) {
         $file = new StorageEntry();
         $file->createFromFile($request->file('image'));
         $product->image()->associate($file);
     }
     $product->account()->associate(Account::findOrFail($request->input('account_id')));
     $categories = [];
     if ($request->has('product_categories') && count($request->input('product_categories')) > 0) {
         foreach ($request->input('product_categories') as $category) {
             $category = ProductCategory::find($category);
             if ($category != null) {
                 $categories[] = $category->id;
             }
         }
     }
     $product->categories()->sync($categories);
     $product->save();
     $request->session()->flash('flash_message', 'The product has been updated.');
     return Redirect::route('omnomcom::products::edit', ['id' => $product->id]);
 }
예제 #10
0
 /**
  * Adds file to page.
  *
  * @param Request $request
  * @param $id
  * @return mixed
  */
 public function addFile(Request $request, $id)
 {
     $page = Page::find($id);
     $file = new StorageEntry();
     $file->createFromFile($request->file('file'));
     $page->files()->attach($file);
     $page->save();
     return Redirect::route('page::edit', ['id' => $id]);
 }