41 lines
1010 B
PHP
41 lines
1010 B
PHP
<?php
|
|
|
|
namespace App\Repositories\Ecommerce\Order;
|
|
|
|
use Closure;
|
|
|
|
class NovaOrderRepository
|
|
{
|
|
/**
|
|
* Mask value
|
|
*
|
|
* @param string $attribute
|
|
*/
|
|
public static function mask($resource, $attribute): Closure
|
|
{
|
|
return fn () => $resource->{$attribute} ? mask_phone($resource->{$attribute}) : '';
|
|
}
|
|
|
|
/**
|
|
* Fill form with masking value mask
|
|
*/
|
|
public static function fillUnmasked(): Closure
|
|
{
|
|
return function ($request, $model, $attribute, $requestAttribute) {
|
|
$model->{$attribute} = unmask_phone($request->input($attribute));
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Depends on
|
|
*/
|
|
public static function dependsOnWhere(string $attribute, string $model): Closure
|
|
{
|
|
return function ($field, $request, $formData) use ($attribute, $model) {
|
|
if ($formData->{$attribute}) {
|
|
$field->options($model::where('region', $formData->{$attribute})->pluck('name', 'id'));
|
|
}
|
|
};
|
|
}
|
|
}
|