enhance components, add mailtemplate, add traits for translations, for stats
This commit is contained in:
58
app/Mail/Acheminement.php
Normal file
58
app/Mail/Acheminement.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Core\Mail\MailTemplate;
|
||||
use App\Repositories\Core\DateTime;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Spatie\MailTemplates\TemplateMailable;
|
||||
use App\Repositories\Shop\Customers;
|
||||
|
||||
|
||||
class Acheminement extends TemplateMailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
protected static $templateModelClass = MailTemplate::class;
|
||||
|
||||
public $user;
|
||||
|
||||
public $male;
|
||||
|
||||
public $subject;
|
||||
|
||||
public $url;
|
||||
|
||||
public function __construct($user, $subject = '')
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->male = $user->gender == 1;
|
||||
$this->subject = $subject;
|
||||
$this->from[] = ['address' => 'boutique@jardinenvie.com','name' => 'Boutique JardinEnVie'];
|
||||
$this->reply_to = ['address' => 'boutique@jardinenvie.com','name' => 'Boutique JardinEnVie'];
|
||||
}
|
||||
|
||||
public static function getDataByUser($user_id)
|
||||
{
|
||||
$user = self::getUser($user_id);
|
||||
|
||||
return $user ? [
|
||||
'user' => $user->toArray(),
|
||||
'male' => $user->gender == 1,
|
||||
] : false;
|
||||
}
|
||||
|
||||
public static function getUser($id)
|
||||
{
|
||||
return Customers::get($id);
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
$data = ['user' => $this->user];
|
||||
$template = $this->getTemplate();
|
||||
return $this->view($template, $data);
|
||||
}
|
||||
|
||||
}
|
||||
58
app/Mail/Bienvenue.php
Normal file
58
app/Mail/Bienvenue.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Core\Mail\MailTemplate;
|
||||
use App\Repositories\Core\DateTime;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Spatie\MailTemplates\TemplateMailable;
|
||||
use App\Repositories\Shop\Customers;
|
||||
|
||||
|
||||
class Bienvenue extends TemplateMailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
protected static $templateModelClass = MailTemplate::class;
|
||||
|
||||
public $user;
|
||||
|
||||
public $male;
|
||||
|
||||
public $subject;
|
||||
|
||||
public $url;
|
||||
|
||||
public function __construct($user, $subject = '')
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->male = $user->gender == 1;
|
||||
$this->subject = $subject;
|
||||
$this->from[] = ['address' => 'boutique@jardinenvie.com','name' => 'Boutique JardinEnVie'];
|
||||
$this->reply_to = ['address' => 'boutique@jardinenvie.com','name' => 'Boutique JardinEnVie'];
|
||||
}
|
||||
|
||||
public static function getDataByUser($user_id)
|
||||
{
|
||||
$user = self::getUser($user_id);
|
||||
|
||||
return $user ? [
|
||||
'user' => $user->toArray(),
|
||||
'male' => $user->gender == 1,
|
||||
] : false;
|
||||
}
|
||||
|
||||
public static function getUser($id)
|
||||
{
|
||||
return Customers::get($id);
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
$data = ['user' => $this->user];
|
||||
$template = $this->getTemplate();
|
||||
return $this->view($template, $data);
|
||||
}
|
||||
|
||||
}
|
||||
58
app/Mail/ConfirmationCommande.php
Normal file
58
app/Mail/ConfirmationCommande.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Core\Mail\MailTemplate;
|
||||
use App\Repositories\Core\DateTime;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Spatie\MailTemplates\TemplateMailable;
|
||||
use App\Repositories\Shop\Customers;
|
||||
|
||||
|
||||
class ConfirmationCommande extends TemplateMailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
protected static $templateModelClass = MailTemplate::class;
|
||||
|
||||
public $user;
|
||||
|
||||
public $male;
|
||||
|
||||
public $subject;
|
||||
|
||||
public $url;
|
||||
|
||||
public function __construct($user, $subject = '')
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->male = $user->gender == 1;
|
||||
$this->subject = $subject;
|
||||
$this->from[] = ['address' => 'boutique@jardinenvie.com','name' => 'Boutique JardinEnVie'];
|
||||
$this->reply_to = ['address' => 'boutique@jardinenvie.com','name' => 'Boutique JardinEnVie'];
|
||||
}
|
||||
|
||||
public static function getDataByUser($user_id)
|
||||
{
|
||||
$user = self::getUser($user_id);
|
||||
|
||||
return $user ? [
|
||||
'user' => $user->toArray(),
|
||||
'male' => $user->gender == 1,
|
||||
] : false;
|
||||
}
|
||||
|
||||
public static function getUser($id)
|
||||
{
|
||||
return Customers::get($id);
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
$data = ['user' => $this->user];
|
||||
$template = $this->getTemplate();
|
||||
return $this->view($template, $data);
|
||||
}
|
||||
|
||||
}
|
||||
58
app/Mail/Preparation.php
Normal file
58
app/Mail/Preparation.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Core\Mail\MailTemplate;
|
||||
use App\Repositories\Core\DateTime;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Spatie\MailTemplates\TemplateMailable;
|
||||
use App\Repositories\Shop\Customers;
|
||||
|
||||
|
||||
class Preparation extends TemplateMailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
protected static $templateModelClass = MailTemplate::class;
|
||||
|
||||
public $user;
|
||||
|
||||
public $male;
|
||||
|
||||
public $subject;
|
||||
|
||||
public $url;
|
||||
|
||||
public function __construct($user, $subject = '')
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->male = $user->gender == 1;
|
||||
$this->subject = $subject;
|
||||
$this->from[] = ['address' => 'boutique@jardinenvie.com','name' => 'Boutique JardinEnVie'];
|
||||
$this->reply_to = ['address' => 'boutique@jardinenvie.com','name' => 'Boutique JardinEnVie'];
|
||||
}
|
||||
|
||||
public static function getDataByUser($user_id)
|
||||
{
|
||||
$user = self::getUser($user_id);
|
||||
|
||||
return $user ? [
|
||||
'user' => $user->toArray(),
|
||||
'male' => $user->gender == 1,
|
||||
] : false;
|
||||
}
|
||||
|
||||
public static function getUser($id)
|
||||
{
|
||||
return Customers::get($id);
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
$data = ['user' => $this->user];
|
||||
$template = $this->getTemplate();
|
||||
return $this->view($template, $data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,8 +11,6 @@ class MailTemplate extends parentMailTemplate
|
||||
{
|
||||
use HasTranslations, RevisionableTrait, Userstamps;
|
||||
|
||||
protected $connection = 'central';
|
||||
|
||||
public $translatable = ['subject', 'html_template', 'text_template'];
|
||||
|
||||
protected $revisionCreationsEnabled = false;
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use Qoraiche\MailEclipse\MailEclipse;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Mailer
|
||||
{
|
||||
public static function getTemplates()
|
||||
{
|
||||
// $mailables = MailEclipse::getMailables();
|
||||
// DB::rollBack();
|
||||
// dump($mailables);
|
||||
/*
|
||||
$mailables = (null !== $mailables) ? $mailables->sortBy('name') : collect([]);
|
||||
foreach ($mailables as $mailable)
|
||||
{
|
||||
$templates[] = $mailable['name'];
|
||||
}
|
||||
|
||||
*/
|
||||
$templates = ['EventInscription','EventSaveTheDate','MatinalesBadge','MatinalesThanks','MatinalesReplays'];
|
||||
return $templates;
|
||||
}
|
||||
|
||||
public static function getTemplate($template_id)
|
||||
{
|
||||
$templates = self::getTemplates();
|
||||
return $templates[$template_id];
|
||||
}
|
||||
}
|
||||
26
app/Traits/HasTranslations.php
Normal file
26
app/Traits/HasTranslations.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use Spatie\Translatable\HasTranslations as BaseHasTranslations;
|
||||
|
||||
trait HasTranslations
|
||||
{
|
||||
use BaseHasTranslations;
|
||||
|
||||
/**
|
||||
* Convert the model instance to an array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
$attributes = parent::toArray();
|
||||
foreach ($this->getTranslatableAttributes() as $field) {
|
||||
$attributes[$field] = $this->getTranslation($field, \App::getLocale());
|
||||
$attributes[$field.'_translations'] = $this->getTranslations($field);
|
||||
}
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
}
|
||||
13
app/Traits/StatHelpers.php
Normal file
13
app/Traits/StatHelpers.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
trait StatHelpers
|
||||
{
|
||||
public static function getLastValue()
|
||||
{
|
||||
$item = self::query()->start(now())->end(now()->subSecond())->groupByDay()->get();
|
||||
|
||||
return $item ? $item[0]->value : 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user