-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a151393
commit c4d95e5
Showing
29 changed files
with
1,015 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Andiwijaya\WebApp; | ||
|
||
use Illuminate\Mail\MailServiceProvider; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class CustomMailServiceProvider extends MailServiceProvider | ||
{ | ||
protected function registerSwiftTransport() | ||
{ | ||
$this->app->singleton('swift.transport', function () { | ||
return new CustomTransportManager($this->app); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Andiwijaya\WebApp; | ||
|
||
use Andiwijaya\WebApp\Models\Config; | ||
use Illuminate\Mail\TransportManager; | ||
|
||
class CustomTransportManager extends TransportManager{ | ||
|
||
public function __construct($app) | ||
{ | ||
$this->app = $app; | ||
|
||
$configs = Config::where('key', 'like', 'smtp%')->get()->groupBy('key'); | ||
|
||
$this->app['config']['mail'] = [ | ||
'driver' => config('mail.driver'), | ||
'host' => $configs['smtp.host'][0]->value ?? config('mail.host'), | ||
'port' => $configs['smtp.port'][0]->value ?? config('mail.port'), | ||
'from' => [ | ||
'address' => config('mail.from.address'), | ||
'name' => config('mail.from.name') | ||
], | ||
'encryption' => $configs['smtp.encryption'][0]->value ?? config('mail.encryption'), | ||
'username' => $configs['smtp.username'][0]->value ?? config('mail.username'), | ||
'password' => $configs['smtp.password'][0]->value ?? config('mail.password'), | ||
'sendmail' => config('mail.sendmail'), | ||
'pretend' => config('mail.pretend') | ||
]; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace Andiwijaya\WebApp\Exports; | ||
|
||
use Illuminate\Support\Collection; | ||
use Maatwebsite\Excel\Concerns\FromCollection; | ||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; | ||
use Maatwebsite\Excel\Concerns\WithEvents; | ||
use Maatwebsite\Excel\Concerns\WithHeadings; | ||
use Maatwebsite\Excel\Events\AfterSheet; | ||
|
||
class GenericExport implements FromCollection, WithHeadings, ShouldAutoSize, WithEvents | ||
{ | ||
protected $columns; | ||
protected $data; | ||
|
||
/** | ||
* @return Collection | ||
*/ | ||
public function collection() | ||
{ | ||
$arr = collect([]); | ||
foreach($this->data as $data){ | ||
|
||
$obj = []; | ||
foreach($this->columns as $idx=>$column) | ||
$obj[] = $data[$idx] ?? ''; | ||
|
||
$arr->add($obj); | ||
} | ||
|
||
return $arr; | ||
} | ||
|
||
public function __construct($columns, $data) | ||
{ | ||
$this->columns = $columns; | ||
$this->data = $data; | ||
} | ||
|
||
public function headings(): array | ||
{ | ||
return $this->columns; | ||
} | ||
|
||
public function registerEvents(): array | ||
{ | ||
return [ | ||
BeforeExport::class => function(BeforeExport $event) { | ||
$event->writer->setCreator(env('APP_NAME')); | ||
}, | ||
AfterSheet::class => function(AfterSheet $event) { | ||
|
||
$event->sheet->styleCells( | ||
'A1:Z1', | ||
[ | ||
'font'=>[ 'bold'=>true ] | ||
] | ||
); | ||
}, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.