mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-11-04 06:23:17 -05:00 
			
		
		
		
	* Create PHP CS Fixer config and add to CI workflow * Run php cs fixer on project * Add newline at end of file * Update to use PHP CS Fixer v3 * Run v3 config on project * Run seperate config in CI
		
			
				
	
	
		
			100 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			100 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace Crater\Http\Controllers\V1\Settings;
 | 
						|
 | 
						|
use Crater\Http\Controllers\Controller;
 | 
						|
use Crater\Http\Requests\MailEnvironmentRequest;
 | 
						|
use Crater\Mail\TestMail;
 | 
						|
use Crater\Models\Setting;
 | 
						|
use Crater\Space\EnvironmentManager;
 | 
						|
use Illuminate\Http\JsonResponse;
 | 
						|
use Illuminate\Http\Request;
 | 
						|
use Mail;
 | 
						|
 | 
						|
class MailConfigurationController extends Controller
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * @var EnvironmentManager
 | 
						|
     */
 | 
						|
    protected $environmentManager;
 | 
						|
 | 
						|
    /**
 | 
						|
     * @param EnvironmentManager $environmentManager
 | 
						|
     */
 | 
						|
    public function __construct(EnvironmentManager $environmentManager)
 | 
						|
    {
 | 
						|
        $this->environmentManager = $environmentManager;
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     *
 | 
						|
     * @param MailEnvironmentRequest $request
 | 
						|
     * @return JsonResponse
 | 
						|
     */
 | 
						|
    public function saveMailEnvironment(MailEnvironmentRequest $request)
 | 
						|
    {
 | 
						|
        $setting = Setting::getSetting('profile_complete');
 | 
						|
        $results = $this->environmentManager->saveMailVariables($request);
 | 
						|
 | 
						|
        if ($setting !== 'COMPLETED') {
 | 
						|
            Setting::setSetting('profile_complete', 4);
 | 
						|
        }
 | 
						|
 | 
						|
        return response()->json($results);
 | 
						|
    }
 | 
						|
 | 
						|
    public function getMailEnvironment()
 | 
						|
    {
 | 
						|
        $MailData = [
 | 
						|
            'mail_driver' => config('mail.driver'),
 | 
						|
            'mail_host' => config('mail.host'),
 | 
						|
            'mail_port' => config('mail.port'),
 | 
						|
            'mail_username' => config('mail.username'),
 | 
						|
            'mail_password' => config('mail.password'),
 | 
						|
            'mail_encryption' => config('mail.encryption'),
 | 
						|
            'from_name' => config('mail.from.name'),
 | 
						|
            'from_mail' => config('mail.from.address'),
 | 
						|
            'mail_mailgun_endpoint' => config('services.mailgun.endpoint'),
 | 
						|
            'mail_mailgun_domain' => config('services.mailgun.domain'),
 | 
						|
            'mail_mailgun_secret' => config('services.mailgun.secret'),
 | 
						|
            'mail_ses_key' => config('services.ses.key'),
 | 
						|
            'mail_ses_secret' => config('services.ses.secret'),
 | 
						|
        ];
 | 
						|
 | 
						|
 | 
						|
        return response()->json($MailData);
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     *
 | 
						|
     * @return JsonResponse
 | 
						|
     */
 | 
						|
    public function getMailDrivers()
 | 
						|
    {
 | 
						|
        $drivers = [
 | 
						|
            'smtp',
 | 
						|
            'mail',
 | 
						|
            'sendmail',
 | 
						|
            'mailgun',
 | 
						|
            'ses',
 | 
						|
        ];
 | 
						|
 | 
						|
        return response()->json($drivers);
 | 
						|
    }
 | 
						|
 | 
						|
    public function testEmailConfig(Request $request)
 | 
						|
    {
 | 
						|
        $this->validate($request, [
 | 
						|
            'to' => 'required|email',
 | 
						|
            'subject' => 'required',
 | 
						|
            'message' => 'required',
 | 
						|
        ]);
 | 
						|
 | 
						|
        Mail::to($request->to)->send(new TestMail($request->subject, $request->message));
 | 
						|
 | 
						|
        return response()->json([
 | 
						|
            'success' => true,
 | 
						|
        ]);
 | 
						|
    }
 | 
						|
}
 |