예제 #1
0
 public function store_links(Request $request)
 {
     $link = Link::findOrNew($request->id);
     $link->link_name = $request->link_name;
     $link->link_url = $request->link_url;
     $link->link_description = $request->link_description;
     $link->course_id = $request->course_id;
     //Upload icons
     if ($request->link_icon != null) {
         $link_icon = uploadFileToS3($request, 'link_icon', 200, $link->link_icon);
         $link->link_icon = $link_icon;
         $link->link_icon_url = $this->s3_url . $link_icon;
     } else {
         if ($link->link_icon_url == null) {
             $link->link_icon_url = 'https://placehold.it/800x600';
         }
     }
     $link->save();
     return redirect('manage/editcourse/' . $request->course_id);
 }
예제 #2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     if (Gate::denies('admin')) {
         abort(403);
     }
     $out = ['form_route' => ['route' => ['link.update', $id], 'method' => 'PUT', 'class' => 'form-horizontal']];
     if (count(Request::old())) {
         $rq = Request::old();
         $out['link'] = new Link($rq);
         if (isset($rq['artist_id']) && is_array($rq['artist_id'])) {
             $out['link']->artists = Artist::whereIn('id', $rq['artist_id'])->get();
         }
         if (isset($rq['release_id']) && is_array($rq['release_id'])) {
             $out['link']->releases = Release::whereIn('id', $rq['release_id'])->get();
         }
         if (isset($rq['track_id']) && is_array($rq['track_id'])) {
             $out['link']->tracks = Track::whereIn('id', $rq['track_id'])->get();
         }
     } else {
         $out['link'] = Link::findOrNew($id);
     }
     return view('links.form', $out);
 }