Last active
April 26, 2018 05:53
-
-
Save danmaina/c9ec2384115e819c9c7ff3f1dad031b7 to your computer and use it in GitHub Desktop.
Laravel Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use App\Image as Img; | |
use Intervention\Image\Facades\Image; | |
/** | |
* With Image Resizing | |
*/ | |
if($request->hasFile('filename')){ | |
$img = $request->file('filename'); | |
$request->filename = time() . '.' . $img->getClientOriginalExtension(); | |
$path = 'img/uploads/'; | |
$img = Image::make($img->getRealPath())->resize(150, 150, function ($constraint){ | |
$constraint->aspectRatio(); | |
}); | |
$img->save($path . '/' . $request->filename); | |
Img::where('page', 'pagename')->where('name', 'filename')->update([ | |
'image_url' => $path . '/' . $request->filename | |
]); | |
} | |
/** | |
* Without Image Resizing | |
*/ | |
if($request->hasFile('filename')){ | |
$img = $request->file('filename'); | |
$request->filename = time() . '.' . $img->getClientOriginalExtension(); | |
$path = 'img/uploads/'; | |
$img = Image::make($img->getRealPath()); | |
$img->save($path . '/' . $request->filename); | |
Img::where('page', 'pagename')->where('name', 'filename')->update([ | |
'image_url' => $path . '/' . $request->filename | |
]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$data = [ | |
'name' => $request->fname . " " . $request->lname, | |
'emailSubject' => $request->subject, | |
'emailAddress' => $request->email, | |
'emailMessage' => $request->message | |
]; | |
Mail::send('email.visit', $data, function ($message) use ($data) { | |
$message->from($data['emailAddress']); | |
$message->subject($data['emailSubject']); | |
$message->to($data['mainadanarin@gmail.com']); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$data = [ | |
'name' => $request->fname . " " . $request->lname, | |
'emailSubject' => $request->subject, | |
'emailAddress' => $request->email, | |
'emailMessage' => $request->message | |
]; | |
Mail::send('email.visit', $data, function ($message) use ($data) { | |
$message->from($data['emailAddress']); | |
$message->subject($data['emailSubject']); | |
$message->to($data['mainadanarin@gmail.com']); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment