mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Fixes for blank settings (#3027)
This commit is contained in:
parent
5fafbac36f
commit
004d39cc73
@ -11,7 +11,9 @@
|
||||
|
||||
namespace App\Http\Requests\Client;
|
||||
|
||||
use App\DataMapper\ClientSettings;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Http\ValidationRules\ValidSettingsRule;
|
||||
use App\Models\Client;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@ -32,11 +34,12 @@ class StoreClientRequest extends Request
|
||||
|
||||
public function rules()
|
||||
{
|
||||
$this->sanitize();
|
||||
|
||||
/* Ensure we have a client name, and that all emails are unique*/
|
||||
$rules['name'] = 'required|min:1';
|
||||
$rules['id_number'] = 'unique:clients,id_number,' . $this->id . ',id,company_id,' . $this->company_id;
|
||||
//$rules['settings'] = 'json';
|
||||
$rules['settings'] = new ValidSettingsRule();
|
||||
|
||||
$contacts = request('contacts');
|
||||
|
||||
@ -58,8 +61,8 @@ class StoreClientRequest extends Request
|
||||
public function sanitize()
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
$input['settings'] = new \stdClass;
|
||||
|
||||
$input['settings'] = ClientSettings::defaults();
|
||||
|
||||
$this->replace($input);
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace App\Http\Requests\Client;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Http\ValidationRules\ValidSettingsRule;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
@ -40,6 +41,7 @@ class UpdateClientRequest extends Request
|
||||
$rules['shipping_country_id'] = 'integer|nullable';
|
||||
//$rules['id_number'] = 'unique:clients,id_number,,id,company_id,' . auth()->user()->company()->id;
|
||||
$rules['id_number'] = 'unique:clients,id_number,' . $this->id . ',id,company_id,' . $this->company_id;
|
||||
$rules['settings'] = new ValidSettingsRule();
|
||||
|
||||
|
||||
// $rules['settings'] = 'json';
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace App\Http\Requests\GroupSetting;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Http\ValidationRules\ValidSettingsRule;
|
||||
use App\Models\GroupSetting;
|
||||
|
||||
class CreateGroupSettingRequest extends Request
|
||||
@ -27,4 +28,5 @@ class CreateGroupSettingRequest extends Request
|
||||
return auth()->user()->can('create', GroupSetting::class);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -11,7 +11,9 @@
|
||||
|
||||
namespace App\Http\Requests\GroupSetting;
|
||||
|
||||
use App\DataMapper\ClientSettings;
|
||||
use App\Http\Requests\Request;
|
||||
use App\Http\ValidationRules\ValidSettingsRule;
|
||||
use App\Models\GroupSetting;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@ -32,22 +34,25 @@ class StoreGroupSettingRequest extends Request
|
||||
|
||||
public function rules()
|
||||
{
|
||||
$this->sanitize();
|
||||
|
||||
return [
|
||||
'name' => 'required',
|
||||
// 'settings' => 'json',
|
||||
];
|
||||
$rules['name'] = 'required';
|
||||
$rules['settings'] = new ValidSettingsRule();
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
||||
public function sanitize()
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
|
||||
$input['settings'] = ClientSettings::defaults();
|
||||
|
||||
$this->replace($input);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace App\Http\Requests\GroupSetting;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Http\ValidationRules\ValidSettingsRule;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
@ -31,9 +32,9 @@ class UpdateGroupSettingRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
|
||||
return [
|
||||
// 'settings' => 'json',
|
||||
];
|
||||
$rules['settings'] = new ValidSettingsRule();
|
||||
|
||||
return $rules;
|
||||
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ class MultiDB
|
||||
|
||||
public static function findAndSetDbByDomain($domain) :bool
|
||||
{
|
||||
//\Log::error("searching for {$domain}");
|
||||
//\Log::error("searching for {$domain}");
|
||||
|
||||
foreach (self::$dbs as $db)
|
||||
{
|
||||
|
@ -148,6 +148,7 @@ class CreateUsersTable extends Migration
|
||||
$table->boolean('custom_surcharge_taxes2')->default(false);
|
||||
$table->boolean('custom_surcharge_taxes3')->default(false);
|
||||
$table->boolean('custom_surcharge_taxes4')->default(false);
|
||||
$table->boolean('show_product_cost')->default(false);
|
||||
$table->unsignedInteger('enabled_tax_rates')->default(1);
|
||||
|
||||
// $table->string('website')->nullable();
|
||||
|
Loading…
Reference in New Issue
Block a user