mahmoudsabry / email-list
There is no license information available for the latest version (dev-main) of this package.
Sample for repository pattern [Storing email for newsletter]
dev-main
2022-12-03 21:50 UTC
Requires
- php: >=7.4
This package is auto-updated.
Last update: 2025-06-29 02:16:43 UTC
README
Sample of using Repository pattern
Get started
Laravel vertions 9.*
Install the package
composer require mahmoudsabry/email-list
Once the package installed successfully, It is autoloaded to the laravel core
Create your Controller
<?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(); } } }