mahmoudsabry/email-list

此软件包的最新版本(dev-main)没有提供许可信息。

存储邮件以用于通讯录的存储库模式示例

dev-main 2022-12-03 21:50 UTC

This package is auto-updated.

Last update: 2024-09-30 01:46:43 UTC


README

使用存储库模式的示例

开始使用

Laravel版本 9.*

安装软件包

composer require mahmoudsabry/email-list

软件包安装成功后,它将自动加载到laravel核心中

创建你的控制器

<?php

namespace App\Http\Controllers;

use MS\EmailList\EmailList;
use App\Http\Controllers\Controller;
use Illuminate\Validation\ValidationException;
use MS\EmailList\Repository\Interfaces\EmailListRepositoryInterface;

class EmailListControllers extends Controller
{

    private $emailList;
    public function __construct(EmailListRepositoryInterface $interface)
    {
        $this->emailList = new EmailList($interface);
    }

    function index(){
       return $this->emailList->index();
    }

    function create(){
        try{
        return $this->emailList->create(request('email'));
        } catch(ValidationException $e)
        {
            return redirect()
            ->back()
            ->withErrors($e->validator)
            ->withInput();
        }
    }

}