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.