public function showHistory()
 {
     $histories = History::with('customer', 'product')->orderBy('command_at')->paginate(6);
     return view('admin.history', compact('histories'));
 }
 /**
  * Display the order histories
  */
 public function index()
 {
     $histories = History::with('product', 'customer')->orderBy('command_at', 'desc')->paginate(20);
     $title = "History";
     return view('admin.history', compact('histories', 'title'));
 }
Example #3
0
 public function histories($id)
 {
     $episode = Episode::find($id, ['id', 'drama_id', 'title']);
     $drama = Drama::find($episode->drama_id, ['title']);
     $histories = History::with(['user' => function ($query) {
         $query->select('id', 'name');
     }])->select('user_id', 'type', 'content', 'created_at')->where('model', 1)->where('model_id', $id)->get();
     return view('episode.histories', ['episode' => $episode, 'drama' => $drama, 'histories' => $histories]);
 }
 public function history()
 {
     $historique = History::with('customer', 'product')->get();
     return view('admin.history', compact('historique'));
 }
 /**
  * Get the beer recommendations for a user.  Create a user's taste profile using the star rating system as a weight
  * and provide recommendations for beers that fall in a user's profile.
  *
  * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  */
 public function recommend()
 {
     // get the history/past beers for a user
     $history = History::with('beer')->where('user_id', '=', $this->user->id)->get();
     // define the variables that serve as predictors
     $count = count($history);
     $starCount = 0;
     $srm = 0;
     $abv = 0;
     $ibu = 0;
     // ensure that the cellar has beers
     if ($count == 0) {
         return response(['status' => 'failed', 'message' => 'To get a recommendation the user\'s cellar must contain beers.']);
     }
     // add variable to its total weighted value
     foreach ($history as $rating) {
         $beer = $rating->beer;
         $starCount += $rating->rating;
         $srm += $beer->srm * $rating->rating;
         $abv += $beer->abv * $rating->rating;
         $ibu += $beer->ibu * $rating->rating;
     }
     // determine the mean weight values
     $srm /= $starCount;
     $abv /= $starCount;
     $ibu /= $starCount;
     // exclude beers that are already in a users cellar
     $usersBeers = $this->user->history()->pluck('beer_id');
     // retrieve beers that fall within a certain range of the means
     $beers = Beer::where('srm', '>=', $srm - 1.5)->where('srm', '<=', $srm + 1.5)->where('ibu', '>=', $ibu - 15)->where('ibu', '<=', $ibu + 15)->where('abv', '>=', $abv - 0.75)->where('abv', '<=', $abv + 0.75)->with('style', 'brewery')->whereNotIn('id', $usersBeers)->get();
     return response(['status' => 'ok', 'message' => 'The following beers are in the user\'s recommendation profile', 'profile' => ['srm' => $srm, 'ibu' => $ibu, 'abv' => $abv], 'beers' => $beers]);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $histories = History::with('product', 'user')->orderBy('command_at', 'desc')->paginate(10);
     return view('admin.history.index', compact('histories'));
 }