Friday, June 10, 2016
How to open downloaded laravel projects from GITHUB on localhost ? | How do I use a github based laravel project? | How to Run a downloaded project from github in Laravel?
It's quite easy how you can actually run a laravel project downloaded from gitHub. Let's follow the following process:
1. You need to download the project from GitHub repository.
2. Extract the file and put it in htdocs
3. Change the DB details in the .env file and also in the /config/database.php ( such as DB_DATABASE, DB_USERNAME, DB_PASSWORD )
4. Then open CMD and Go to the directory where the project is usign command prompt.
5. Enter the command : composer install
6. Enter the command : php artisan migrate
7. Enter the command: php artisan db:seed (if it has any seeder table)
7. Enter the command: php artisan db:seed (if it has any seeder table)
7. That's it. So if yo run the project on the browser you can easily access it.
That's for today. Hope you liked and stay tune for the next tutorial. Thank you!
That's for today. Hope you liked and stay tune for the next tutorial. Thank you!
Tuesday, June 7, 2016
How to send Email with Laravel? | Sending Email with Laravel | How to setup email configuration and send email in Laravel?
Today's tutorial about Sending Email with Laravel. Email sending is very much useful for an application. Marketing, newsletters, adverts, notification, credentials etc are the main reason you need to send emails to your client. In this tutorial we use gmail as email service provider. So Lets start how you can send email easily with your laravel Project.
1. First open your .env file in your project as here we gonna change some configuration for sending mail.
See the before by default .env setting in MAIL section with fresh laravel installation you get. And here we need to change the setting.
See the before by default .env setting in MAIL section with fresh laravel installation you get. And here we need to change the setting.
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
And after changing the setting we get this:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=youremail@gmail.com
MAIL_PASSWORD=youremailpassword
MAIL_ENCRYPTION=tls
2. Now from your root folder goto Config folder and inside of this open the mail.php as here also we need to change some setting:
Before change of setting with fresh installation we get this in that mail.php file:
Before change of setting with fresh installation we get this in that mail.php file:
<?php return [ 'driver' => env('MAIL_DRIVER', 'smtp'), 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 'port' => env('MAIL_PORT', 587), 'from' => ['address' => null, 'name' => null], 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 'username' => env('MAIL_USERNAME'), 'password' => env('MAIL_PASSWORD'), 'sendmail' => '/usr/sbin/sendmail -bs', ];
And after changing the setting we will get this:
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => 'youremail@gmail.com', 'name' =>'YourGmailUserName'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
3. Our task in almost done. Now we gonna set the routes.php and make a controller.php to send the email. Let's start with routes
4. In routes.php we need to initialize in which user it will send the user. I have given a demo code you can change with your required code as it's almost same.
Route::get('/sendMail/{id}',[
'uses' =>'AppController@sendEmail',
'as' =>'sendMail',
]);
5. We have to make a view page as we need to send the email with that page only. So here we gonna make a send.blade.php in resources/views folder which we'll send as email.
send.blade.php:
<html>
<head> Email Demo</head>
<body>
<p>Thanks for Registering with User Id</p>
</body>
</html>
6. Now let's a create a RESTful Resource Controller for sending Email. Here we have created sendEmail controller.
public function sendEmail(Request $request, $id)
{
$user = User::findOrFail($id);
Mail::send('mail', ['user' => $user], function ($m) use ($user) {
$m->from('youremail@gmail.com', 'yourName');
$m->to($user->email, $user->name)->subject('Thanks!');
});
return redirect('/');
}
ooh ..don't forget to use namespace use Mail; above of your controller.
That's it. It will find the user with the $id using findOrFail() then it will send the mail matches with the user information from database.
Thanks for reading the whole article. Hope you can send Email with Laravel now with these easy steps. And if you face any problem don't forget to ping me on comment.
Thanks for reading the whole article. Hope you can send Email with Laravel now with these easy steps. And if you face any problem don't forget to ping me on comment.
Sunday, June 5, 2016
Phone Number Validation in Laravel | How to Validate Phone Number in Laravel?
In this tutorial I'm gonna show how you can validate user phone number using Laravel Validation Request. As we know usually we write the validation request in Controller. So Let's define a controller where we will show the validation rule.
Controller:
public function saveUser(Request $request){
$this->validate($request,[
'name' => 'required|max:120',
'email' => 'required|email|unique:users',
//'phone' => 'required|numeric|size:11'
'phone' => 'required|regex:/(01)[0-9]{9}/'
]);
$user = new User();
$user->name= $request->Input(['name']);
$user->email= $request->Input(['email']);
$user->phone= $request->Input(['phone']);
$user->save();
return redirect('success');
}
As we can see here I have used two validation rule which one you prefer use that one.
//'phone' => 'required|numeric|size:11'
'phone' => 'required|regex:/(01)[0-9]{9}/'
First one I have used for checking phone number. As Phone number should be numeric I have used numeric and it should be 11.
In Second one I have used Regular Expression for validation. Where Phone number should be 11 digit where it starts with 01 and following 9 digit would as regard from any any digit from 0 to 9.
Here I have shown two process of Phone number validation. You can also create your own validation rule.
That's it for today. Stay connected for the next session.
Thank you!
Saturday, June 4, 2016
PHP Laravel : Important Artisan Command
1. For Generating Migrated Database.It will automatically generate User table in databaseafter fresh installation of Laravel
php artisan migrate
2. For Installing composer in the required project or the project you have downloaded from the git repository.
composer install
3. For Updating Composer in Laravel Project. (Mostly required when we install a new package in existing project)
composer update
4. For Creating table in database. (Here I'm creating option table).
php artisan make:migration create_option_table
5. For generating unique key/ product key in your laravel project.
php artisan key:generate
6. For making New Controller in your Laravel Project. (Here I'm making TodoController)
php artisan make:controller TodoController
7. For Creating New Model in your project.( Here I'm creating Task Model )
php artisan make:model Task
8. For Creating Model as well as Table. ( Here I'm creating Task Model and tasks table with the below command)
php artisan make:model Task -m
9. Laravel provides a quick way to generate all of the routes and views you need for authentication by below command:
php artisan make:auth
10. For showing all the artisan command
php artisan
11. For listing out the routes you have used in your project:
php artisan route:list
12. For createting Event and listener we can use following command:
php artisan event:generate
How to Download Instagram Photo? | How do I download Instagram Photo from PC?
Many of us want to download Instagram photo but don't know how to download photo from it. Some of you might have used downloader to download those photos. But it's very to download photo from Instagram from PC and you don't need to install any software also. Let's start..
1. First login to your Instagram Account. After login you will see your news feed like following screen.
1. First login to your Instagram Account. After login you will see your news feed like following screen.
2. Now press Ctrl+Shift+I (Inspect Element from browser right click) in your logged in webpage. And it will open console like the following screen.
3. Now click on Resource -> Frame (see the left corner) -> choose www.instagram.com -> Images. ( For Instruction : See the following Image)
4. A list of images you will see in these images folder. Now select the image you want to download. Right click on it and select Open image in new tab. and the real image with full width and height will be loaded in next tab.
5. Now in new tab you will see the image what you selected recently and right click on it and select Save image as and it will automatically download the image.
That's it. See how easily you can download now Instagram images from your PC.
Stay connected. See you in next tutorial. Thank you!









