laravel queues and jobs

 queue and jobs

laravel queue-> first in fort out








for example to process some tasks it needs too much time, for that type we need have to throw to some place, after some time we have to execute automatically



fifo -> it will wait to complete to complete the previous task





 





to execiute all jobs
php artisan queue:work


  1. Which artisan command generates jobs migrations?

    Marked Answer : queue:table

    Correct Answer : queue:table

  2. Queueable jobs are stored in _______ directory.

    Marked Answer : app/Queue

    Correct Answer : app/Jobs

  3. Which queue drivers supported in Laravel?

    Marked Answer : All of the above

    Correct Answer : All of the above

  4. Which command is used to start a queue worker?

    Marked Answer : queue:work

    Correct Answer : queue:work

  5. Which method is invoked when the job is processed by the queue?

    Marked Answer : handle()

    Correct Answer : handle()





laravel mail


 



laravel is fifo first in first out

each type of mail is one class in app/mail directoru

to genearte mailabe class

php artisan make:mail learvernemail

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=73@gmail.com
MAIL_PASSWORD=""
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=ie73@gmail.com
MAIL_FROM_NAME="No Reply"
CC_MAIL="73@gmail.com"
BCC_MAIL="jdv@gmail.com"

core php 

php mailer

 php artisan make:mail maillabletempalte

<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class MaillableTemplate extends Mailable
{
use Queueable, SerializesModels;
public $details;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($details)
{
$this->details = $details;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
// $template = 'emails.demoMail';
if ($this->details){
$template = 'emails.'.$this->details['mail_type'];
} else {
$template ='emails.demoMail';
}
return $this->markdown($template)
->subject($this->details['subject'])
->with('details', $this->details);
}
}


use queueable -> trait




blade
resources/mail

<!DOCTYPE html>
<html>
<head>
<title>Laravel 8 Send Email Example</title>
</head>
<body>
<h1>This is test mail from </h1>
<p>Laravel 8 send email example</p>
</body>
</html>

in controller 

use App\Mail\MaillableTemplate;
use App\Jobs\SendEmail as SEJ;


$details = [
'title' => 'Successfully updated Profile',
'description'=>'description',
'url' => 's',
'subject' => 'Successfully updated Profile',
'email' => 'narayanavamsikrishna@gmail.com',
'password' =>'s',
'username' => 's',
'mail_type' =>'registrationTemplate'
];
dispatch(new SEJ($details));


SEND EMIAL JOB

<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use App\Mail\MaillableTemplate;
use Mail;
class SendEmail implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $details;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($details)
{
$this->details = $details;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$myccEmail=env('CC_MAIL');
$mybccEmail =env('BCC_MAIL');
$mail= Mail::to($this->details['email'])->cc($myccEmail)->bcc($mybccEmail);
$mail->send(new MaillableTemplate($this->details));
}
}


MAIL/WELCOMEMAIL.PHP



with('emaildata')
CONTROLLER

    



CC(['sdsd','']]);

BCC(mailinator)

S



select the local language



send from languages folder




testmail.blade.php




html_mail.blade.php

message.tabline
html_mail.blade.php



laravel validations

 illuminate vie middleware shareerrorsfromsessions middleware



accepted validation rules in laravel

AcceptedAccepted IfActive URLAfter (Date)After Or Equal (Date)AlphaAlpha DashAlpha NumericArrayBailBefore (Date)Before Or Equal (Date)BetweenBooleanConfirmedCurrent PasswordDateDate EqualsDate FormatDeclinedDeclined IfDifferentDigitsDigits BetweenDimensions (Image Files)DistinctEmailEnds WithEnumExcludeExclude IfExclude UnlessExclude WithoutExists (Database)FileFilledGreater ThanGreater Than Or EqualImage (File)InIn ArrayIntegerIP AddressMAC AddressJSONLess ThanLess Than Or EqualMaxMIME TypesMIME Type By File ExtensionMinMultiple OfNot InNot RegexNullableNumericPasswordPresentProhibitedProhibited IfProhibited UnlessProhibitsRegular ExpressionRequiredRequired IfRequired UnlessRequired WithRequired With AllRequired WithoutRequired Without AllSameSizeSometimesStarts WithStringTimezoneUnique (Database)URLUUID

$this ->validate();

$this->validate($request,[]);

$this->validate($request, [

'title' =>'required|min:2|max:50',
'image'=> 'required|mimes:jpeg,jpg,png|max:5120',
'description' =>'required|min:2',
'meta_desc' =>'required|min:2|max:255',
'category' =>'required|min:2|max:50',


]);
  1. Which method is used to validate incoming HTTP Requests?

    Marked Answer : validate()

    Correct Answer : validate()

  2. The validate() method is provided by _______ object.

    Marked Answer : IlluminateHttpValidate

    Correct Answer : Illuminate\Http\Request

  3. Which validation rule is used to Stopping On First Validation Failure?

    Marked Answer : unique

    Correct Answer : bail

  4. Which variable is shared with all of application's views?

    Marked Answer : $error

    Correct Answer : $errors

  5. ____ Blade directive is used to determine if validation error messages exist for a given attribute.

    Marked Answer : "@error"

    Correct Answer : "@error"

Event listening in react

 How we can listen to som eevents some envents fire like click or automatically user enters into input button , that is event on word type i...