File size: 1,889 Bytes
40dca3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php

use Illuminate\Support\Facades\Validator;
use Carbon\Carbon;
use Illuminate\Support\MessageBag;
use Illuminate\Support\Collection;

function getInformationDataTable($pagination)
{
    return trans('project.data_table.information', [
        'first_item' => $pagination->firstItem(),
        'last_item' => $pagination->lastItem(),
        'total' => $pagination->total()
    ]);

}

function getArray($modal)
{
    if ($modal instanceof Collection) {
        $arrays = [];
        $modal->each(function ($item) use (&$arrays) {
            $arrays[] = $item->id;
        });
        return $arrays;
    }
    return null;
}


function getLinkSpinImg()
{
    return asset('assets/images/loadspinner.svg');
}

function getPaginationArrays($paginator)
{
    $currentPage = $paginator->currentPage();
    $lastPage = $paginator->lastPage();
    $min = 0;
    $max = $lastPage + 1;
    $tmp_min = $currentPage - 2;
    $tmp_max = $currentPage + 2;
    // next
    if ($currentPage - 1 <= $min) {
        $tmp_max++;
    }
    if ($currentPage - 2 <= $min) {
        $tmp_max++;
    }

    if ($currentPage + 1 >= $max) {
        $tmp_min--;
    }
    if ($currentPage + 2 >= $max) {
        $tmp_min--;
    }
    $tmp_min = $tmp_min <= $min ? 1 : $tmp_min;
    $tmp_max = $tmp_max > $lastPage ? $lastPage : $tmp_max;
    return [$tmp_min, $tmp_max];
}

function convertComicIdtoString($comicId)
{
    return convertString($comicId, config('settings.arrray_keys_convert_id'));
}

function convertString($input, $keyArray)
{
    $output = '';
    foreach (str_split($input) as $char) {
        $position = array_search($char, $keyArray);
        $output .= $position;
    }
    return $output;
}

function reverseConvert($input, $keyArray)
{
    $output = '';
    foreach (str_split($input) as $num) {
        $char = $keyArray[$num];
        $output .= $char;
    }
    return $output;
}