[PHP] [BiuldYourFirstApp] to build your first application: Mandrill

Source: Internet
Author: User
Tags dmca
[PHP] [BiuldYourFirstApp] build your first application: Mandrill this article applies to beginners who have some knowledge of PHP and laravel frameworks and have read the laravel getting started video: Laravel 5 Fundamentals. This article describes how to build a web application with simple registration, logon, form filling, text generation, preview, email sending, and display.

The video of the video author is often illegally uploaded to youtube. if you want to report to the relevant authorities, you must fill in a DMCA file with the source video address and the video address illegally uploaded, and express some demands. For convenience, the website is designed to enter a form to automatically generate DMCA files and send emails automatically.

If you haven't seen it yet, please download and watch it first:

  • Link: http://pan.baidu.com/s/1sjXeLQH
  • Password extraction: jjb5

1. simplify the Auth: user () that appears multiple times in the text and directly declare it in the parent class.

Parent class

 user = $this->signedIn = Auth::user();    } } 

Subclass

 Middleware ('auth '); // register a middleware to verify all methods. parent ::__ construct (); // inherit the constructor of the parent class and add new content} public function index () {return $ this-> user-> notices;} public function create () {// get list of providers $ provider = Provider: list ('name', 'id'); // load a view to create a new notice return view ('Notices. create ', compact ('Providers');} pubilcfunction confirm (PrepareNoticeRequest $ request) {$ template = $ this-> compileDmcaTemplate ($ data = $ request-> all (); session ()-> flash ('dmca ', $ data ); return view ('Notices. comfirm', compact ('Template'); // return a new view page and check the filled form data} public function store () {$ this-> creaeNotice ($ request); return redirect ('notices');} public function compileDmcaTemplate ($ data) {$ data = $ data + ['name' => $ this-> user-> name, 'Email '=> $ this-> user-> email,]; // input data for the template and splice the data return view ()-> file (app_path ('http/Templates/dmca. blade. php '), $ data);} private function createNotice (Request $ request) {$ notice = session ()-> get ('dmca ') + ['template' => $ request-> input ('Template')]; $ notice = $ this-> user-> notices ()-> save ($ notice ); return $ notice ;}}

2. install the relevant components before using ManDrill, and run the command composer require guzzlehttp/guzzle :~ 4.0. Configure MAIL_DRIVER = mandrill in the environment configuration. In config/services. php, configure 'mandrill => ['secret => 'Register mandrill to get apikey'].

Send notice

Successful

Summary

This section uses the mandrill engine to send emails.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.