注册验证邮件在流明中发送

时间:2017-06-12 06:35:11

标签: php laravel registration lumen

应用/助手/ EmailVerification.php

<?php

namespace App\Http\Controllers;
use Illuminate\Support\Facades\Mail;

class mailcontroller extends Controller {

    public function mail(){
        Mail::raw('Raw string email', function($msg) {
            $msg->to(['****.com']);
            $msg->from(['*****@gmail.com']);
        });
    }
}

应用/立面/ EmailVerification.php

<?php
namespace App\Facades;

use Illuminate\Support\Facades\Facade;
use Illuminate\Support\Facades\Mail;

class EmailVerification extends Facade
{
    protected static function getFacadeAccessor()
    {
        return 'emailverification';
    }
}

?>

应用/提供商/ EmailVerificationServiceProvider.php

<?php
namespace App\Providers;

use App\Helper\ProfilePrivacy;

use Queue;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Log;



class EmailVerificationServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        Queue::failing(function ($event) {
        });
    }


    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->singleton('mailer', function ($app) {
            $app->configure('services');
            return $app->loadComponent('mail', 'Illuminate\Mail\MailServiceProvider', 'mailer');
        });$this->app->singleton('mailer', function ($app) {
        $app->configure('services');
        return $app->loadComponent('mail', 'Illuminate\Mail\MailServiceProvider', 'mailer');
    });
    }
}

我希望在用户注册邮件生成后使用此Facade来使用

这里是用户控制器代码

应用/ HTTP /控制器/ UserController.php

public function register(Request $request)
    {
        $data = $request->all();
        $validator = Validator::make($data, 
                    array('name' => 'bail|alpha', 'mobile' => 'bail|required_without:username|regex:/^\+[1-9]{1}[0-9]{3,14}$/', 'email' => 'nullable|email', 'username' => 'required_without:mobile|alpha_dash',
                    'password' => 'required_with:username|min:8', 'password_confirmation' => 'required_with:password|same:password', 'gender' => ['nullable', Rule::in(['m', 'f'])], 
                    'birthday' => 'nullable|date_format:"Y-m-d"', 'lat' => 'bail|nullable|numeric', 'lng' => 'bail|nullable|numeric', 'city' => 'nullable|alpha', 'country' => 'nullable|alpha', 
                    'app_id' => 'bail|required', 'device_id' => 'bail|required', 'device_serial_no' => 'bail|required', 'imei_no' => 'bail|required'),
                    array('password_confirmation.same' => 'The password confirmation field should match the password.'));

        if ($validator->fails()) {
            $this->_response->status = 'INVALID_PARAMS';
            $this->_response->message = array_flatten($validator->errors()->getMessages());
        } else {
            $result = $this->_model->register($data);

            if ($result != false) {
                $this->_response = $result;


            } else {
                $this->_response->status = 'FAILURE';
                $this->_response->message = 'failed';

            }
        }

        return response()->json($this->_response);
    }

0 个答案:

没有答案