Skip to content

Instantly share code, notes, and snippets.

@segun6060
Created March 10, 2017 21:40
Show Gist options
  • Save segun6060/305d4c067f970c5747e0af4dda739af1 to your computer and use it in GitHub Desktop.
Save segun6060/305d4c067f970c5747e0af4dda739af1 to your computer and use it in GitHub Desktop.
public function caller(Request $request)
{
$this->validate($request,[
'avatar' => 'required|image|max:10240',
'reciever_id' => 'required',
]);
$image = new Imagene;
//change model name Image to something else because u are using Image as alias if u not then it will give u a errors
$image->user_id = Auth::user()->id;
$image->reciever_id = $request->reciever_id;
if ($request->hasFile('avatar'))
{
$avatar = $request->file('avatar');
$filename = time().'.'.$avatar->getClientOriginalExtension();
$location = public_path('images/'.$filename);
Image::make($avatar)->resize(300,300)->save($location);
$image->name=$filename;
$image->save();
}
Session::flash('success','The proof has been recieved you will be comfirm soon!');
return back();
}
<form action="/caller" method="POST" class="form-inline" enctype="multipart/form-data">
<a href="#">
{{ csrf_field() }}
<div class="form-group hideform" style="display:none;">
<input name="reciever_id" value="{{ $message->reciever_id}}" class="form-control" type="text" required="" />
</div>
<div class="form-group">
<input name="avatar" class="form-control" type="file" required="" />
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary pull-right" value="submit">
</div>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment