simplify variables names for templates, refactor to be multi-model

This commit is contained in:
Ludovic CANDELLIER
2023-03-28 00:17:04 +02:00
parent 3dc6c70c4d
commit bc1cf1190b
11 changed files with 89 additions and 75 deletions

View File

@@ -18,6 +18,11 @@ class Customers
return Customer::count();
}
public static function getOptions()
{
return Customer::pluck('last_name', 'id');
}
public static function editProfile($id = false)
{
$id = $id ? $id : self::getId();

View File

@@ -0,0 +1,41 @@
<?php
namespace App\Repositories\Shop\Traits;
use App\Repositories\Shop\Customers;
use App\Repositories\Core\DateTime;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Envelope;
trait MailCustomers
{
public static function getContext()
{
return Customers::getOptions();
}
public static function getData($id)
{
$user = self::getUser($id);
return $user ? [
'prenom' => $user->first_name,
'nom' => $user->last_name,
'societe' => $user->society,
'email' => $user->email,
] : false;
}
public static function getUser($id)
{
return Customers::get($id);
}
public function envelope()
{
return new Envelope(
from: new Address('boutique@jardinenvie.com', 'Jardin\'en\'Vie'),
subject: $this->subject,
);
}
}