improved helper function

master
A1Gard 2 weeks ago
parent 33a60eb170
commit bbae5955d5

@ -199,7 +199,7 @@ function sortSuffix($col): string
* @param $translate * @param $translate
* @return false|string * @return false|string
*/ */
function arrayNormolizeVueCompatible($array, $translate = false): false|string function arrayNormalizeVueCompatible($array, $translate = false): false|string
{ {
$result = []; $result = [];
foreach ($array as $index => $item) { foreach ($array as $index => $item) {
@ -264,7 +264,7 @@ function gfx()
/** /**
* build query with excepts * http build query with excepts
* @param $except * @param $except
* @return string * @return string
*/ */
@ -963,9 +963,9 @@ function success($data = null, $message = null, $meta = [], $og = [], $twitter =
$defaultOg = [ $defaultOg = [
'url' => null, 'url' => null,
'type' => null, 'type' => null,
'site_name' => env('APP_NAME'), 'site_name' => config('app.name'),
'description' => null, 'description' => null,
'locate' => 'fa_IR' 'locate' => config('app.locale')
]; ];
$defaultTwitter = [ $defaultTwitter = [
@ -977,7 +977,7 @@ function success($data = null, $message = null, $meta = [], $og = [], $twitter =
]; ];
return response()->json([ return response()->json([
"success" => true, "OK" => true,
"message" => $message, "message" => $message,
"data" => $data, "data" => $data,
"meta" => array_merge($defaultMeta, $meta), "meta" => array_merge($defaultMeta, $meta),
@ -997,7 +997,7 @@ function success($data = null, $message = null, $meta = [], $og = [], $twitter =
function errors($errors, $status = 422, $message = null, $data = null) function errors($errors, $status = 422, $message = null, $data = null)
{ {
return response()->json([ return response()->json([
"success" => false, "OK" => false,
"errors" => $errors, "errors" => $errors,
"message" => $message, "message" => $message,
"data" => $data, "data" => $data,
@ -1011,7 +1011,7 @@ function errors($errors, $status = 422, $message = null, $data = null)
*/ */
function readable($text) function readable($text)
{ {
return ucfirst(trim(str_replace(['-', '_'], ' ', $text))); return ucfirst(trim(str_replace(['-', '_','.'], ' ', $text)));
} }
@ -1113,7 +1113,12 @@ function tagUrl($slug)
return fixUrlLang(route('client.tag', $slug)); return fixUrlLang(route('client.tag', $slug));
} }
function usableProp($props)
/**
* @param $props
* @return array
*/
function usableProp($props): array
{ {
$result = []; $result = [];

@ -101,7 +101,7 @@
{{__('Status')}} {{__('Status')}}
</label> </label>
<searchable-select <searchable-select
:items='{{arrayNormolizeVueCompatible(\App\Models\Invoice::$invoiceStatus, true)}}' :items='{{arrayNormalizeVueCompatible(\App\Models\Invoice::$invoiceStatus, true)}}'
title-field="name" title-field="name"
value-field="name" value-field="name"
xname="status" xname="status"

@ -13,7 +13,7 @@
{{__("Status")}}: {{__("Status")}}:
</h2> </h2>
<searchable-multi-select <searchable-multi-select
:items='{{arrayNormolizeVueCompatible(\App\Models\Invoice::$invoiceStatus, true)}}' :items='{{arrayNormalizeVueCompatible(\App\Models\Invoice::$invoiceStatus, true)}}'
title-field="name" title-field="name"
value-field="name" value-field="name"
xname="filter[status]" xname="filter[status]"

@ -13,7 +13,7 @@
{{__("Status")}}: {{__("Status")}}:
</h2> </h2>
<searchable-multi-select <searchable-multi-select
:items='{{arrayNormolizeVueCompatible(\App\Models\Ticket::$ticket_statuses, true)}}' :items='{{arrayNormalizeVueCompatible(\App\Models\Ticket::$ticket_statuses, true)}}'
title-field="name" title-field="name"
value-field="name" value-field="name"
xname="filter[status]" xname="filter[status]"

@ -75,7 +75,7 @@
{{__('Role')}} {{__('Role')}}
</label> </label>
<searchable-select <searchable-select
:items='{{arrayNormolizeVueCompatible(\App\Models\User::$roles, true)}}' :items='{{arrayNormalizeVueCompatible(\App\Models\User::$roles, true)}}'
title-field="name" title-field="name"
value-field="name" value-field="name"
xname="role" xname="role"

@ -13,7 +13,7 @@
{{__("Role filter")}}: {{__("Role filter")}}:
</h2> </h2>
<searchable-multi-select <searchable-multi-select
:items='{{arrayNormolizeVueCompatible(\App\Models\User::$roles, true)}}' :items='{{arrayNormalizeVueCompatible(\App\Models\User::$roles, true)}}'
title-field="name" title-field="name"
value-field="name" value-field="name"
xname="filter[role]" xname="filter[role]"

Loading…
Cancel
Save