Skip to content

Commit

Permalink
Add Favorite list function
Browse files Browse the repository at this point in the history
  • Loading branch information
yukiyukiyu committed Aug 14, 2016
1 parent 7479de0 commit 90a4150
Show file tree
Hide file tree
Showing 6 changed files with 5,091 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/FavList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class FavList extends Model
{
protected $table = 'favlist';
}
19 changes: 19 additions & 0 deletions app/Http/Controllers/GoodController.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,23 @@ public function quickAccess(Request $request)
$data['is_admin'] = NULL;
return view::make('good.goodList')->with($data);
}

/*
* @funtion addFavlist
* @input $request (use query)
*
* @return Redirect or View
* @description Process the query and add to certain
* user's favorite list
*/
public function addFavlist(Request $request, $good_id)
{
if(!$request->session()->has('user_id'))
return Redirect::back();
$fav = new FavList;
$fav->user_id = $request->session()->get('user_id');
$fav->good_id = $good_id;
$fav->save();
return Redirect::to('/good');
}
}
5 changes: 5 additions & 0 deletions app/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
"middleware" => "auth"
]);

Route::get('/good/{good_id}/add_favlist', [
"uses" => "GoodController@addFavlist",
"middleware" => "auth"
]);

Route::get('/good/{good_id}/check', [
"uses" => "AdminController@checkGood",
"middleware" => "auth"
Expand Down
Loading

0 comments on commit 90a4150

Please sign in to comment.