public function indexGames() { $games = Game::get(); $bgg = new \App\Bgg(); $uploadr = new \App\Uploadr(); foreach ($games as $game) { $url = 'http:' . $bgg->getGameImage($game->bgg_id); $path = $uploadr->uploadFromUrl($url, $game->id, 'game'); $game->photo = $path; $game->save(); } return redirect()->back(); }
public function store(Request $request) { $this->validate($request, ['name' => 'required|max:255|unique:games', 'description' => 'required', 'bgg_id' => 'required']); $game = new Game(); $game->name = $request->name; $game->description = $request->description; $game->bgg_id = $request->bgg_id; if ($request->has('scorable')) { $game->scorable = 1; } $game->save(); $bgg = new \App\Bgg(); $url = 'http:' . $bgg->getGameImage($request->input('bgg_id')); $uploadr = new \App\Uploadr(); $path = $uploadr->uploadFromUrl($url, $game->id, 'game'); $game->photo = $path; $game->save(); return redirect()->route('game'); }
public function store(Request $request) { $messages = ['required_if' => 'The :attribute field is required.']; $this->validate($request, ['username' => 'required|max:255|unique:users', 'nickname' => 'required|max:255|unique:users', 'email' => 'required_if:account,1|email|max:255|unique:users', 'password' => 'required_if:account,1|confirmed|min:6'], $messages); if ($request->has('password')) { $password = bcrypt($request->input('password')); } else { $password = '******'; } $file = $request->file('photo'); $user = User::create(['username' => $request->input('username'), 'email' => $request->input('email', null), 'password' => $password]); $user->nickname = $request->input('nickname'); if ($file) { $uploadr = new \App\Uploadr(); $path = $uploadr->upload($request->file('photo'), round($request->height), round($request->width), 'user', 'test', round($request->offsetx), round($request->offsety)); $user->profile_photo = $path; } $user->save(); return redirect()->route('player'); }