示例#1
0
 public function updateLink(Request $req, $id)
 {
     $link = Links::find($id);
     if ($req->isMethod('post')) {
         $parametres = $req->except(['_token']);
         $link->nom = $parametres['nom'];
         $link->link = $parametres['lien'];
         $link->description = $parametres['description'];
         $link->save();
         return redirect()->route('listLink')->with('ok', 'Lien modifié');
     }
     return view('link/addLink')->with('link', $link);
 }
示例#2
0
 /**
  * Sort the specified resource from storage.
  *
  */
 public function sort()
 {
     foreach (\Input::get('link') as $key => $id) {
         Links::find($id)->update(['line' => $key]);
     }
     \Activity::log('Link Sıralaması Değiştirildi');
 }
示例#3
0
 /**
  * Update to increase the downvotes of a link.
  *
  * @param  int  $id
  * @return Response
  */
 public function downvote($id)
 {
     //retrieve entry for current link
     if (is_null(Votes::where(['userid' => Auth::user()->id, 'linkid' => $id])->first())) {
         $link = Links::find($id);
         $link->downvotes += 1;
         $link->save();
         $newVote = Votes::create(['linkid' => $id, 'userid' => Auth::user()->id, 'vote' => -1]);
         $newVote->save();
     } else {
         return redirect()->action('LinkController@index')->withErrors(['You have already voted.']);
     }
     return redirect()->action('LinkController@index');
 }