[PHP] [Biuld Your First app] Build your application: Mandrill

Source: Internet
Author: User
Tags compact dmca
This article is intended for beginners who have a certain understanding of the PHP and laravel framework and have read the Laravel introductory video: Laravel 5 Fundamentals. This article explains how to build a Web app that has simple registration, login, fill out forms, generate text, preview, send mail, and show.

Video author videos are often illegally uploaded on YouTube and want to reflect to the authorities the need to fill out a DMCA file with the source video address and an illegally uploaded video address, as well as to express some claims. For convenience, the website is designed to fill out the form automatically generated by the DMCA file automatically sent by mail.

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

    • Links: Http://pan.baidu.com/s/1sjXeLQH
    • Extract Password: jjb5

1. Simplified Auth::user (), which appears more than once in the text, is declared directly in the parent class.

Parent class

 
  user = $this->signedin = Auth::user ();    

Sub-class

 Middleware (' auth ');//Register a middleware to validate all methods parent::__construct ();//Inherit the constructor of the parent class and add new content} public Function index () {retur  N $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 = $reque       St->all ());       Session ()->flash (' DMCA ', $data); Return view (' Notices.comfirm ', compact (' template '));//Return a new view page to check the completed form data} public function Store () {$this->cre       Aenotice ($request);  Return redirect (' notices ');          The Public Function compiledmcatemplate ($data) {$data = $data + [' name ' = = $this->user->name, ' Email ' + $this->user->email,];//for the template incoming data, splicing 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 appropriate components first before using Mandrill, and use the command composer require guzzlehttp/guzzle:~4.0. Configure the appropriate Mail_driver=mandrill in the environment configuration. In config/services.php, configure ' Mandrill = [' secret = ' register Mandrill get APIkey '].

Send Notice

Success

Summary

This section uses the Mandrill engine for sending mail functionality.

  • Related Article

    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.