diff --git a/.env.example b/.env.example index 69a8f98..53c0e7c 100644 --- a/.env.example +++ b/.env.example @@ -27,7 +27,7 @@ REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379 -MAIL_DRIVER=smtp +MAIL_MAILER=smtp MAIL_HOST=smtp MAIL_PORT=25 MAIL_USERNAME=null diff --git a/app/Console/Commands/InvoiceEmail.php b/app/Console/Commands/InvoiceEmail.php index 2599566..0263658 100644 --- a/app/Console/Commands/InvoiceEmail.php +++ b/app/Console/Commands/InvoiceEmail.php @@ -35,15 +35,17 @@ class InvoiceEmail extends Command $o = Invoice::findOrFail($this->argument('id')); - Mail::to($o->account->user->email)->send(new \App\Mail\InvoiceEmail($o)); + $result = Mail::to($o->account->user->email)->send(new \App\Mail\InvoiceEmail($o)); try { $o->print_status = TRUE; - $o->reminders = $o->reminders('send'); + //$o->reminders = $o->reminders('send'); $o->save(); } catch (\Exception $e) { dd($e); } + + dump($result->getDebug()); } } \ No newline at end of file diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php deleted file mode 100644 index a921282..0000000 --- a/app/Console/Kernel.php +++ /dev/null @@ -1,46 +0,0 @@ -job(new BroadbandTraffic(Supplier::find(1)))->timezone('Australia/Melbourne')->dailyAt('10:00'); - } - - /** - * Register the commands for the application. - * - * @return void - */ - protected function commands() - { - $this->load(__DIR__.'/Commands'); - - require base_path('routes/console.php'); - } -} diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index b7b53cb..c578c82 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -2,6 +2,8 @@ namespace App\Http\Controllers; +use Clarkeash\Doorman\Exceptions\{ExpiredInviteCode,InvalidInviteCode,NotYourInviteCode}; +use Clarkeash\Doorman\Facades\Doorman; use Illuminate\View\View; use Barryvdh\Snappy\Facades\SnappyPdf as PDF; @@ -33,10 +35,20 @@ class InvoiceController extends Controller * Render a specific invoice for the user * * @param Invoice $o + * @param string|null $code * @return View */ - public function view(Invoice $o): View + public function view(Invoice $o,string $code=NULL): View { + if ($code) { + try { + Doorman::redeem($code,$o->account->user->email); + + } catch (ExpiredInviteCode|InvalidInviteCode|NotYourInviteCode $e) { + abort(404); + } + } + return view('theme.backend.adminlte.invoice.view') ->with('o',$o); } diff --git a/app/Mail/InvoiceEmail.php b/app/Mail/InvoiceEmail.php index ce89fd9..784f5c7 100644 --- a/app/Mail/InvoiceEmail.php +++ b/app/Mail/InvoiceEmail.php @@ -2,6 +2,7 @@ namespace App\Mail; +use App\Models\Site; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Mail\Mailable; @@ -15,6 +16,7 @@ class InvoiceEmail extends Mailable use Queueable, SerializesModels; public $invoice; + public $site; /** * Create a new message instance. @@ -33,10 +35,11 @@ class InvoiceEmail extends Mailable */ public function build() { - Config::set('site',$this->invoice->site); + Config::set('site',Site::findOrFail($this->invoice->site_id)); + $this->site = config('site'); return $this - ->markdown('email.user.invoice') + ->markdown('email.user.invoice',['site'=>config('site')]) ->subject(sprintf( 'Invoice: %s - Total: $%s - Due: %s', $this->invoice->id, number_format($this->invoice->total,2), diff --git a/app/Models/Product.php b/app/Models/Product.php index b2391e4..9309074 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -132,7 +132,7 @@ class Product extends Model implements IDs return $this->hasOne(ProductTranslate::class) ->where('language_id',(Auth::user() && Auth::user()->language_id) ? Auth::user()->language_id - : config('site')->language_id); + : config('osb.language_id')); } /** diff --git a/config/doorman.php b/config/doorman.php new file mode 100644 index 0000000..595b016 --- /dev/null +++ b/config/doorman.php @@ -0,0 +1,65 @@ + 'invites', + + /* + |-------------------------------------------------------------------------- + | Invite Model Class + |-------------------------------------------------------------------------- + | + | This option allows you to override the default model. + | Your model MUST extend the base Invite model. + | + | Default: Clarkeash\Doorman\Models\Invite::class + */ + 'invite_model' => Clarkeash\Doorman\Models\Invite::class, + + /* + |-------------------------------------------------------------------------- + | Default Code Generator + |-------------------------------------------------------------------------- + | + | This option controls how the invite codes are generated. + | You should adjust this based on your needs. + | + | Supported: "basic", "uuid" + | + */ + 'driver' => env('DOORMAN_DRIVER', 'basic'), + + /* + |-------------------------------------------------------------------------- + | Driver Configurations + |-------------------------------------------------------------------------- + | + | Here are each of the driver configurations for your application. + | You can customize should your application require it. + | + */ + 'basic' => [ + 'length' => 6, + ], + + /* + |-------------------------------------------------------------------------- + | UUID + |-------------------------------------------------------------------------- + | + | supported versions: 1,3,4,5 + | + | Versions 3 & 5, require 'namespace' and 'name' to be set + | + */ + 'uuid' => [ + 'version' => 4, + ], + +]; diff --git a/config/osb.php b/config/osb.php new file mode 100644 index 0000000..5c2f2fd --- /dev/null +++ b/config/osb.php @@ -0,0 +1,5 @@ + 1, +]; \ No newline at end of file