Level 30
hello,
which one returns the error? Image, or $games? They both use a save() method.
I get a error when trying to upload a image, this generates the error:
public function updatelogo(Request $request)
{
$game_id = $request->input('game');
$games = DB::table('games')->where('id', $game_id)->first();
if($request->hasFile('logo')){
$logo = $request->file('logo');
$filename = time() . '.' . $logo->getClientOriginalExtension();
Image::make($logo)->resize(50, 50)->save( public_path('/images/games/' . $filename ) );
$games->logourl = $filename;
$games->save();
return redirect()->back()->with("status", "Succesfully edited!");
}
}
This is the frontend:
<form role="form" enctype="multipart/form-data" action="{{ url('/admin/sitesettings/games/edit/logo') }}" method="POST">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="form-group">
<label for="logo" class="col-md-4 control-label">Logo</label>
<small>Upload a logo for the game:</small>
<select name="game" id="game">
@foreach($games as $game)
<option value="{{$game->id}}">{{$game->id}}</option>
@endforeach
</select>
<div>
<input id="logo" type="file" class="form-control" name="logo">
</div>
</div>
</div>
<button type="submit" class="btn btn-primary">Save changes</button>
</form>
Thanks in advance!
ok so, because you're using DB::table, $games is an object I would say, without looking at the doc. But for sure it's not an Eloquent model, therefore doesn't have a save() method. Try to get the game via an Eloquent model and you should be fine.
Please or to participate in this conversation.