/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { if ($this->route('app')) { $id = $this->route('app'); $user = $this->user(); return App::where('id', '=', $id)->where('user_id', '=', $user->id)->exists(); } return $this->user() ? true : false; }
public function appView($app_id) { $appInfo = App::dataHandle(App::find($app_id)); if (!$appInfo) { header('Location:' . action('App\\Http\\Controllers\\HomeController@index')); } $commendApps = App::dataHandle(App::where('category_id', '=', $appInfo->category_id)->where('id', '!=', $app_id)->orderBy('download', 'desc')->take(4)->get()); return view('index.appView')->with(['appInfo' => $appInfo, 'commendApps' => $commendApps]); }
public static function findByUserAndId($user, $id) { return App::where('id', '=', $id)->where('user_id', '=', $user->id)->firstOrFail(); }