FrittenKeeZ / laravel-vouchers

Voucher system for Laravel 9+
MIT License
55 stars 15 forks source link

Allow to set a custom database connection in config file #8

Closed pdrolima closed 2 years ago

pdrolima commented 2 years ago

Hello!

This PR add the possibility to set a custom database connection in config. This is very useful when you want to store the data in another database or to "force" relationships between two different databases connections (which is my case).

It's a pretty simple addition, but very useful.

FrittenKeeZ commented 2 years ago

Hey @webmasterdro,

This seems a bit out of scope for this project, as you can manually override the connection by extending the base models used in this project.

<?php

namespace App\Models;

use FrittenKeeZ\Vouchers\Models\Voucher as BaseVoucher;

class Voucher extends BaseVoucher
{
    /**
     * The connection name for the model.
     *
     * @var string|null
     */
    protected $connection = 'other_connection';
}

But thank you for your suggestion!