Completed
Push — master ( de5c78...60eb24 )
by Sherif
09:23
created
lang/ar/passwords.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 return [
4 4
 
5
-    /*
5
+	/*
6 6
     |--------------------------------------------------------------------------
7 7
     | Password Reminder Language Lines
8 8
     |--------------------------------------------------------------------------
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
     |
14 14
     */
15 15
 
16
-    'password' => 'يجب أن لا يقل طول كلمة السر عن ستة أحرف، كما يجب أن تتطابق مع حقل التأكيد',
17
-    'reset'    => 'تمت إعادة تعيين كلمة السر',
18
-    'sent'     => 'تم إرسال تفاصيل استعادة كلمة السر الخاصة بك إلى بريدك الإلكتروني',
19
-    'token'    => '.رمز استعادة كلمة السر الذي أدخلته غير صحيح',
20
-    'user'     => 'لم يتم العثور على أيّ حسابٍ بهذا العنوان الإلكتروني',
16
+	'password' => 'يجب أن لا يقل طول كلمة السر عن ستة أحرف، كما يجب أن تتطابق مع حقل التأكيد',
17
+	'reset'    => 'تمت إعادة تعيين كلمة السر',
18
+	'sent'     => 'تم إرسال تفاصيل استعادة كلمة السر الخاصة بك إلى بريدك الإلكتروني',
19
+	'token'    => '.رمز استعادة كلمة السر الذي أدخلته غير صحيح',
20
+	'user'     => 'لم يتم العثور على أيّ حسابٍ بهذا العنوان الإلكتروني',
21 21
 
22 22
 ];
Please login to merge, or discard this patch.
lang/ar/pagination.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 return [
4 4
 
5
-    /*
5
+	/*
6 6
     |--------------------------------------------------------------------------
7 7
     | Pagination Language Lines
8 8
     |--------------------------------------------------------------------------
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     |
14 14
     */
15 15
 
16
-    'previous' => '« السابق',
17
-    'next'     => 'التالي »',
16
+	'previous' => '« السابق',
17
+	'next'     => 'التالي »',
18 18
 
19 19
 ];
Please login to merge, or discard this patch.
lang/ar/auth.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 return [
4 4
 
5
-    /*
5
+	/*
6 6
     |--------------------------------------------------------------------------
7 7
     | Authentication Language Lines
8 8
     |--------------------------------------------------------------------------
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     |
14 14
     */
15 15
 
16
-    'failed'   => 'بيانات الاعتماد هذه غير متطابقة مع البيانات المسجلة لدينا.',
17
-    'throttle' => 'عدد كبير جدا من محاولات الدخول. يرجى المحاولة مرة أخرى بعد :seconds ثانية.',
16
+	'failed'   => 'بيانات الاعتماد هذه غير متطابقة مع البيانات المسجلة لدينا.',
17
+	'throttle' => 'عدد كبير جدا من محاولات الدخول. يرجى المحاولة مرة أخرى بعد :seconds ثانية.',
18 18
 
19 19
 ];
Please login to merge, or discard this patch.
lang/ar/validation.php 1 patch
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 return [
4 4
 
5
-    /*
5
+	/*
6 6
     |--------------------------------------------------------------------------
7 7
     | Validation Language Lines
8 8
     |--------------------------------------------------------------------------
@@ -13,76 +13,76 @@  discard block
 block discarded – undo
13 13
     |
14 14
     */
15 15
 
16
-    'accepted'             => 'يجب قبول الحقل :attribute',
17
-    'active_url'           => 'الحقل :attribute لا يُمثّل رابطًا صحيحًا',
18
-    'after'                => 'يجب على الحقل :attribute أن يكون تاريخًا لاحقًا للتاريخ :date.',
19
-    'alpha'                => 'يجب أن لا يحتوي الحقل :attribute سوى على حروف',
20
-    'alpha_dash'           => 'يجب أن لا يحتوي الحقل :attribute على حروف، أرقام ومطّات.',
21
-    'alpha_num'            => 'يجب أن يحتوي :attribute على حروفٍ وأرقامٍ فقط',
22
-    'array'                => 'يجب أن يكون الحقل :attribute ًمصفوفة',
23
-    'before'               => 'يجب على الحقل :attribute أن يكون تاريخًا سابقًا للتاريخ :date.',
24
-    'between'              => [
25
-        'numeric' => 'يجب أن تكون قيمة :attribute محصورة ما بين :min و :max.',
26
-        'file'    => 'يجب أن يكون حجم الملف :attribute محصورًا ما بين :min و :max كيلوبايت.',
27
-        'string'  => 'يجب أن يكون عدد حروف النّص :attribute محصورًا ما بين :min و :max',
28
-        'array'   => 'يجب أن يحتوي :attribute على عدد من العناصر محصورًا ما بين :min و :max',
29
-    ],
30
-    'boolean'              => 'يجب أن تكون قيمة الحقل :attribute إما true أو false ',
31
-    'confirmed'            => 'حقل التأكيد غير مُطابق للحقل :attribute',
32
-    'date'                 => 'الحقل :attribute ليس تاريخًا صحيحًا',
33
-    'date_format'          => 'لا يتوافق الحقل :attribute مع الشكل :format.',
34
-    'different'            => 'يجب أن يكون الحقلان :attribute و :other مُختلفان',
35
-    'digits'               => 'يجب أن يحتوي الحقل :attribute على :digits رقمًا/أرقام',
36
-    'digits_between'       => 'يجب أن يحتوي الحقل :attribute ما بين :min و :max رقمًا/أرقام ',
37
-    'dimensions'           => 'The :attribute has invalid image dimensions.',
38
-    'distinct'             => 'للحقل :attribute قيمة مُكرّرة.',
39
-    'email'                => 'يجب أن يكون :attribute عنوان بريد إلكتروني صحيح البُنية',
40
-    'exists'               => 'الحقل :attribute لاغٍ',
41
-    'file'                 => 'The :attribute must be a file.',
42
-    'filled'               => 'الحقل :attribute إجباري',
43
-    'image'                => 'يجب أن يكون الحقل :attribute صورةً',
44
-    'in'                   => 'الحقل :attribute لاغٍ',
45
-    'in_array'             => 'الحقل :attribute غير موجود في :other.',
46
-    'integer'              => 'يجب أن يكون الحقل :attribute عددًا صحيحًا',
47
-    'ip'                   => 'يجب أن يكون الحقل :attribute عنوان IP ذي بُنية صحيحة',
48
-    'json'                 => 'يجب أن يكون الحقل :attribute نصآ من نوع JSON.',
49
-    'max'                  => [
50
-        'numeric' => 'يجب أن تكون قيمة الحقل :attribute أصغر من :max.',
51
-        'file'    => 'يجب أن يكون حجم الملف :attribute أصغر من :max كيلوبايت',
52
-        'string'  => 'يجب أن لا يتجاوز طول النّص :attribute :max حروفٍ/حرفًا',
53
-        'array'   => 'يجب أن لا يحتوي الحقل :attribute على أكثر من :max عناصر/عنصر.',
54
-    ],
55
-    'mimes'                => 'يجب أن يكون الحقل ملفًا من نوع : :values.',
56
-    'min'                  => [
57
-        'numeric' => 'يجب أن تكون قيمة الحقل :attribute أكبر من :min.',
58
-        'file'    => 'يجب أن يكون حجم الملف :attribute أكبر من :min كيلوبايت',
59
-        'string'  => 'يجب أن يكون طول النص :attribute أكبر من :min حروفٍ/حرفًا',
60
-        'array'   => 'يجب أن يحتوي الحقل :attribute على الأقل على :min عُنصرًا/عناصر',
61
-    ],
62
-    'not_in'               => 'الحقل :attribute لاغٍ',
63
-    'numeric'              => 'يجب على الحقل :attribute أن يكون رقمًا',
64
-    'present'              => 'The :attribute field must be present.',
65
-    'regex'                => 'صيغة الحقل :attribute .غير صحيحة',
66
-    'required'             => 'الحقل :attribute مطلوب.',
67
-    'required_if'          => 'الحقل :attribute مطلوب في حال ما إذا كان :other يساوي :value.',
68
-    'required_unless'      => 'الحقل :attribute مطلوب في حال ما لم يكن :other يساوي :values.',
69
-    'required_with'        => 'الحقل :attribute إذا توفّر :values.',
70
-    'required_with_all'    => 'الحقل :attribute إذا توفّر :values.',
71
-    'required_without'     => 'الحقل :attribute إذا لم يتوفّر :values.',
72
-    'required_without_all' => 'الحقل :attribute إذا لم يتوفّر :values.',
73
-    'same'                 => 'يجب أن يتطابق الحقل :attribute مع :other',
74
-    'size'                 => [
75
-        'numeric' => 'يجب أن تكون قيمة :attribute أكبر من :size.',
76
-        'file'    => 'يجب أن يكون حجم الملف :attribute أكبر من :size كيلو بايت.',
77
-        'string'  => 'يجب أن يحتوي النص :attribute عن ما لا يقل عن  :size حرفٍ/أحرف.',
78
-        'array'   => 'يجب أن يحتوي الحقل :attribute عن ما لا يقل عن:min عنصرٍ/عناصر',
79
-    ],
80
-    'string'               => 'يجب أن يكون الحقل :attribute نصآ.',
81
-    'timezone'             => 'يجب أن يكون :attribute نطاقًا زمنيًا صحيحًا',
82
-    'unique'               => 'قيمة الحقل :attribute مُستخدمة من قبل',
83
-    'url'                  => 'صيغة الرابط :attribute غير صحيحة',
16
+	'accepted'             => 'يجب قبول الحقل :attribute',
17
+	'active_url'           => 'الحقل :attribute لا يُمثّل رابطًا صحيحًا',
18
+	'after'                => 'يجب على الحقل :attribute أن يكون تاريخًا لاحقًا للتاريخ :date.',
19
+	'alpha'                => 'يجب أن لا يحتوي الحقل :attribute سوى على حروف',
20
+	'alpha_dash'           => 'يجب أن لا يحتوي الحقل :attribute على حروف، أرقام ومطّات.',
21
+	'alpha_num'            => 'يجب أن يحتوي :attribute على حروفٍ وأرقامٍ فقط',
22
+	'array'                => 'يجب أن يكون الحقل :attribute ًمصفوفة',
23
+	'before'               => 'يجب على الحقل :attribute أن يكون تاريخًا سابقًا للتاريخ :date.',
24
+	'between'              => [
25
+		'numeric' => 'يجب أن تكون قيمة :attribute محصورة ما بين :min و :max.',
26
+		'file'    => 'يجب أن يكون حجم الملف :attribute محصورًا ما بين :min و :max كيلوبايت.',
27
+		'string'  => 'يجب أن يكون عدد حروف النّص :attribute محصورًا ما بين :min و :max',
28
+		'array'   => 'يجب أن يحتوي :attribute على عدد من العناصر محصورًا ما بين :min و :max',
29
+	],
30
+	'boolean'              => 'يجب أن تكون قيمة الحقل :attribute إما true أو false ',
31
+	'confirmed'            => 'حقل التأكيد غير مُطابق للحقل :attribute',
32
+	'date'                 => 'الحقل :attribute ليس تاريخًا صحيحًا',
33
+	'date_format'          => 'لا يتوافق الحقل :attribute مع الشكل :format.',
34
+	'different'            => 'يجب أن يكون الحقلان :attribute و :other مُختلفان',
35
+	'digits'               => 'يجب أن يحتوي الحقل :attribute على :digits رقمًا/أرقام',
36
+	'digits_between'       => 'يجب أن يحتوي الحقل :attribute ما بين :min و :max رقمًا/أرقام ',
37
+	'dimensions'           => 'The :attribute has invalid image dimensions.',
38
+	'distinct'             => 'للحقل :attribute قيمة مُكرّرة.',
39
+	'email'                => 'يجب أن يكون :attribute عنوان بريد إلكتروني صحيح البُنية',
40
+	'exists'               => 'الحقل :attribute لاغٍ',
41
+	'file'                 => 'The :attribute must be a file.',
42
+	'filled'               => 'الحقل :attribute إجباري',
43
+	'image'                => 'يجب أن يكون الحقل :attribute صورةً',
44
+	'in'                   => 'الحقل :attribute لاغٍ',
45
+	'in_array'             => 'الحقل :attribute غير موجود في :other.',
46
+	'integer'              => 'يجب أن يكون الحقل :attribute عددًا صحيحًا',
47
+	'ip'                   => 'يجب أن يكون الحقل :attribute عنوان IP ذي بُنية صحيحة',
48
+	'json'                 => 'يجب أن يكون الحقل :attribute نصآ من نوع JSON.',
49
+	'max'                  => [
50
+		'numeric' => 'يجب أن تكون قيمة الحقل :attribute أصغر من :max.',
51
+		'file'    => 'يجب أن يكون حجم الملف :attribute أصغر من :max كيلوبايت',
52
+		'string'  => 'يجب أن لا يتجاوز طول النّص :attribute :max حروفٍ/حرفًا',
53
+		'array'   => 'يجب أن لا يحتوي الحقل :attribute على أكثر من :max عناصر/عنصر.',
54
+	],
55
+	'mimes'                => 'يجب أن يكون الحقل ملفًا من نوع : :values.',
56
+	'min'                  => [
57
+		'numeric' => 'يجب أن تكون قيمة الحقل :attribute أكبر من :min.',
58
+		'file'    => 'يجب أن يكون حجم الملف :attribute أكبر من :min كيلوبايت',
59
+		'string'  => 'يجب أن يكون طول النص :attribute أكبر من :min حروفٍ/حرفًا',
60
+		'array'   => 'يجب أن يحتوي الحقل :attribute على الأقل على :min عُنصرًا/عناصر',
61
+	],
62
+	'not_in'               => 'الحقل :attribute لاغٍ',
63
+	'numeric'              => 'يجب على الحقل :attribute أن يكون رقمًا',
64
+	'present'              => 'The :attribute field must be present.',
65
+	'regex'                => 'صيغة الحقل :attribute .غير صحيحة',
66
+	'required'             => 'الحقل :attribute مطلوب.',
67
+	'required_if'          => 'الحقل :attribute مطلوب في حال ما إذا كان :other يساوي :value.',
68
+	'required_unless'      => 'الحقل :attribute مطلوب في حال ما لم يكن :other يساوي :values.',
69
+	'required_with'        => 'الحقل :attribute إذا توفّر :values.',
70
+	'required_with_all'    => 'الحقل :attribute إذا توفّر :values.',
71
+	'required_without'     => 'الحقل :attribute إذا لم يتوفّر :values.',
72
+	'required_without_all' => 'الحقل :attribute إذا لم يتوفّر :values.',
73
+	'same'                 => 'يجب أن يتطابق الحقل :attribute مع :other',
74
+	'size'                 => [
75
+		'numeric' => 'يجب أن تكون قيمة :attribute أكبر من :size.',
76
+		'file'    => 'يجب أن يكون حجم الملف :attribute أكبر من :size كيلو بايت.',
77
+		'string'  => 'يجب أن يحتوي النص :attribute عن ما لا يقل عن  :size حرفٍ/أحرف.',
78
+		'array'   => 'يجب أن يحتوي الحقل :attribute عن ما لا يقل عن:min عنصرٍ/عناصر',
79
+	],
80
+	'string'               => 'يجب أن يكون الحقل :attribute نصآ.',
81
+	'timezone'             => 'يجب أن يكون :attribute نطاقًا زمنيًا صحيحًا',
82
+	'unique'               => 'قيمة الحقل :attribute مُستخدمة من قبل',
83
+	'url'                  => 'صيغة الرابط :attribute غير صحيحة',
84 84
 
85
-    /*
85
+	/*
86 86
     |--------------------------------------------------------------------------
87 87
     | Custom Validation Language Lines
88 88
     |--------------------------------------------------------------------------
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
     |
94 94
     */
95 95
 
96
-    'custom'               => [
97
-        'attribute-name' => [
98
-            'rule-name' => 'custom-message',
99
-        ],
100
-    ],
96
+	'custom'               => [
97
+		'attribute-name' => [
98
+			'rule-name' => 'custom-message',
99
+		],
100
+	],
101 101
 
102
-    /*
102
+	/*
103 103
     |--------------------------------------------------------------------------
104 104
     | Custom Validation Attributes
105 105
     |--------------------------------------------------------------------------
@@ -110,36 +110,36 @@  discard block
 block discarded – undo
110 110
     |
111 111
     */
112 112
 
113
-    'attributes'           => [
114
-        'name'                  => 'الاسم',
115
-        'username'              => 'اسم المُستخدم',
116
-        'email'                 => 'البريد الالكتروني',
117
-        'first_name'            => 'الاسم',
118
-        'last_name'             => 'اسم العائلة',
119
-        'password'              => 'كلمة السر',
120
-        'password_confirmation' => 'تأكيد كلمة السر',
121
-        'city'                  => 'المدينة',
122
-        'country'               => 'الدولة',
123
-        'address'               => 'العنوان',
124
-        'phone'                 => 'الهاتف',
125
-        'mobile'                => 'الجوال',
126
-        'age'                   => 'العمر',
127
-        'sex'                   => 'الجنس',
128
-        'gender'                => 'النوع',
129
-        'day'                   => 'اليوم',
130
-        'month'                 => 'الشهر',
131
-        'year'                  => 'السنة',
132
-        'hour'                  => 'ساعة',
133
-        'minute'                => 'دقيقة',
134
-        'second'                => 'ثانية',
135
-        'title'                 => 'اللقب',
136
-        'content'               => 'المُحتوى',
137
-        'description'           => 'الوصف',
138
-        'excerpt'               => 'المُلخص',
139
-        'date'                  => 'التاريخ',
140
-        'time'                  => 'الوقت',
141
-        'available'             => 'مُتاح',
142
-        'size'                  => 'الحجم',
143
-    ],
113
+	'attributes'           => [
114
+		'name'                  => 'الاسم',
115
+		'username'              => 'اسم المُستخدم',
116
+		'email'                 => 'البريد الالكتروني',
117
+		'first_name'            => 'الاسم',
118
+		'last_name'             => 'اسم العائلة',
119
+		'password'              => 'كلمة السر',
120
+		'password_confirmation' => 'تأكيد كلمة السر',
121
+		'city'                  => 'المدينة',
122
+		'country'               => 'الدولة',
123
+		'address'               => 'العنوان',
124
+		'phone'                 => 'الهاتف',
125
+		'mobile'                => 'الجوال',
126
+		'age'                   => 'العمر',
127
+		'sex'                   => 'الجنس',
128
+		'gender'                => 'النوع',
129
+		'day'                   => 'اليوم',
130
+		'month'                 => 'الشهر',
131
+		'year'                  => 'السنة',
132
+		'hour'                  => 'ساعة',
133
+		'minute'                => 'دقيقة',
134
+		'second'                => 'ثانية',
135
+		'title'                 => 'اللقب',
136
+		'content'               => 'المُحتوى',
137
+		'description'           => 'الوصف',
138
+		'excerpt'               => 'المُلخص',
139
+		'date'                  => 'التاريخ',
140
+		'time'                  => 'الوقت',
141
+		'available'             => 'مُتاح',
142
+		'size'                  => 'الحجم',
143
+	],
144 144
 
145 145
 ];
Please login to merge, or discard this patch.
src/Modules/Core/BaseClasses/BaseRepository.php 3 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
      *
28 28
      * @param  array   $relations
29 29
      * @param  string  $sortBy
30
-     * @param  boolean $desc
30
+     * @param  integer $desc
31 31
      * @param  array   $columns
32 32
      * @return collection
33 33
      */
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      * @param  integer $perPage
44 44
      * @param  array   $relations
45 45
      * @param  string  $sortBy
46
-     * @param  boolean $desc
46
+     * @param  integer $desc
47 47
      * @param  array   $columns
48 48
      * @return collection
49 49
      */
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      * @param  integer $perPage
62 62
      * @param  array   $relations
63 63
      * @param  string  $sortBy
64
-     * @param  boolean $desc
64
+     * @param  integer $desc
65 65
      * @param  array   $columns
66 66
      * @return collection
67 67
      */
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      * Save the given model to the storage.
77 77
      *
78 78
      * @param  array $data
79
-     * @return mixed
79
+     * @return boolean
80 80
      */
81 81
     public function save(array $data)
82 82
     {
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      * @param  array   $conditions array of conditions
133 133
      * @param  array   $relations
134 134
      * @param  string  $sortBy
135
-     * @param  boolean $desc
135
+     * @param  integer $desc
136 136
      * @param  array   $columns
137 137
      * @return collection
138 138
      */
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      * @param  array   $conditions array of conditions
165 165
      * @param  integer $perPage
166 166
      * @param  string  $sortBy
167
-     * @param  boolean $desc
167
+     * @param  integer $desc
168 168
      * @param  array   $columns
169 169
      * @return collection
170 170
      */
Please login to merge, or discard this patch.
Indentation   +561 added lines, -561 removed lines patch added patch discarded remove patch
@@ -8,575 +8,575 @@
 block discarded – undo
8 8
 
9 9
 abstract class BaseRepository implements BaseRepositoryInterface
10 10
 {
11
-    /**
12
-     * @var object
13
-     */
14
-    public $model;
11
+	/**
12
+	 * @var object
13
+	 */
14
+	public $model;
15 15
     
16
-    /**
17
-     * Init new object.
18
-     *
19
-     * @var mixed model
20
-     * @return  void
21
-     */
22
-    public function __construct($model)
23
-    {
24
-        $this->model  = $model;
25
-    }
26
-
27
-    /**
28
-     * Fetch all records with relations from the storage.
29
-     *
30
-     * @param  array   $relations
31
-     * @param  string  $sortBy
32
-     * @param  boolean $desc
33
-     * @param  array   $columns
34
-     * @return collection
35
-     */
36
-    public function all($relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
37
-    {
38
-        $sort = $desc ? 'desc' : 'asc';
39
-        return $this->model->with($relations)->orderBy($sortBy, $sort)->get($columns);
40
-    }
16
+	/**
17
+	 * Init new object.
18
+	 *
19
+	 * @var mixed model
20
+	 * @return  void
21
+	 */
22
+	public function __construct($model)
23
+	{
24
+		$this->model  = $model;
25
+	}
26
+
27
+	/**
28
+	 * Fetch all records with relations from the storage.
29
+	 *
30
+	 * @param  array   $relations
31
+	 * @param  string  $sortBy
32
+	 * @param  boolean $desc
33
+	 * @param  array   $columns
34
+	 * @return collection
35
+	 */
36
+	public function all($relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
37
+	{
38
+		$sort = $desc ? 'desc' : 'asc';
39
+		return $this->model->with($relations)->orderBy($sortBy, $sort)->get($columns);
40
+	}
41 41
     
42
-    /**
43
-     * Fetch all records with relations from storage in pages.
44
-     *
45
-     * @param  integer $perPage
46
-     * @param  array   $relations
47
-     * @param  string  $sortBy
48
-     * @param  boolean $desc
49
-     * @param  array   $columns
50
-     * @return collection
51
-     */
52
-    public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
53
-    {
54
-        $sort = $desc ? 'desc' : 'asc';
55
-        return $this->model->with($relations)->orderBy($sortBy, $sort)->paginate($perPage, $columns);
56
-    }
57
-
58
-    /**
59
-     * Fetch all records with relations based on
60
-     * the given condition from storage in pages.
61
-     *
62
-     * @param  array   $conditions array of conditions
63
-     * @param  integer $perPage
64
-     * @param  array   $relations
65
-     * @param  string  $sortBy
66
-     * @param  boolean $desc
67
-     * @param  array   $columns
68
-     * @return collection
69
-     */
70
-    public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
71
-    {
72
-        $conditions = $this->constructConditions($conditions, $this->model);
73
-        $sort       = $desc ? 'desc' : 'asc';
74
-        return $this->model->with($relations)->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->paginate($perPage, $columns);
75
-    }
76
-
77
-    /**
78
-     * Count all records based on the given condition from storage.
79
-     *
80
-     * @param  array   $conditions array of conditions
81
-     * @return collection
82
-     */
83
-    public function count($conditions)
84
-    {
85
-        $conditions = $this->constructConditions($conditions, $this->model);
86
-        return $this->model->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->count();
87
-    }
42
+	/**
43
+	 * Fetch all records with relations from storage in pages.
44
+	 *
45
+	 * @param  integer $perPage
46
+	 * @param  array   $relations
47
+	 * @param  string  $sortBy
48
+	 * @param  boolean $desc
49
+	 * @param  array   $columns
50
+	 * @return collection
51
+	 */
52
+	public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
53
+	{
54
+		$sort = $desc ? 'desc' : 'asc';
55
+		return $this->model->with($relations)->orderBy($sortBy, $sort)->paginate($perPage, $columns);
56
+	}
57
+
58
+	/**
59
+	 * Fetch all records with relations based on
60
+	 * the given condition from storage in pages.
61
+	 *
62
+	 * @param  array   $conditions array of conditions
63
+	 * @param  integer $perPage
64
+	 * @param  array   $relations
65
+	 * @param  string  $sortBy
66
+	 * @param  boolean $desc
67
+	 * @param  array   $columns
68
+	 * @return collection
69
+	 */
70
+	public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
71
+	{
72
+		$conditions = $this->constructConditions($conditions, $this->model);
73
+		$sort       = $desc ? 'desc' : 'asc';
74
+		return $this->model->with($relations)->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->paginate($perPage, $columns);
75
+	}
76
+
77
+	/**
78
+	 * Count all records based on the given condition from storage.
79
+	 *
80
+	 * @param  array   $conditions array of conditions
81
+	 * @return collection
82
+	 */
83
+	public function count($conditions)
84
+	{
85
+		$conditions = $this->constructConditions($conditions, $this->model);
86
+		return $this->model->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->count();
87
+	}
88 88
     
89
-    /**
90
-     * Save the given model to the storage.
91
-     *
92
-     * @param  array $data
93
-     * @return mixed
94
-     */
95
-    public function save(array $data)
96
-    {
97
-        \Session::put('locale', 'all');
98
-        $model      = false;
99
-        $relations  = [];
100
-
101
-        \DB::transaction(function () use (&$model, &$relations, $data) {
89
+	/**
90
+	 * Save the given model to the storage.
91
+	 *
92
+	 * @param  array $data
93
+	 * @return mixed
94
+	 */
95
+	public function save(array $data)
96
+	{
97
+		\Session::put('locale', 'all');
98
+		$model      = false;
99
+		$relations  = [];
100
+
101
+		\DB::transaction(function () use (&$model, &$relations, $data) {
102 102
             
103
-            $model     = $this->prepareModel($data);
104
-            $relations = $this->prepareRelations($data, $model);
105
-            $model     = $this->saveModel($model, $relations);
106
-        });
103
+			$model     = $this->prepareModel($data);
104
+			$relations = $this->prepareRelations($data, $model);
105
+			$model     = $this->saveModel($model, $relations);
106
+		});
107 107
         
108
-        if (count($relations)) {
109
-            $model->load(...array_keys($relations));
110
-        }
111
-
112
-        return $model;
113
-    }
114
-
115
-    /**
116
-     * Delete record from the storage based on the given
117
-     * condition.
118
-     *
119
-     * @param  var $value condition value
120
-     * @param  string $attribute condition column name
121
-     * @return void
122
-     */
123
-    public function delete($value, $attribute = 'id')
124
-    {
125
-        \DB::transaction(function () use ($value, $attribute) {
126
-            $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function ($model) {
127
-                $model->delete();
128
-            });
129
-        });
130
-    }
108
+		if (count($relations)) {
109
+			$model->load(...array_keys($relations));
110
+		}
111
+
112
+		return $model;
113
+	}
114
+
115
+	/**
116
+	 * Delete record from the storage based on the given
117
+	 * condition.
118
+	 *
119
+	 * @param  var $value condition value
120
+	 * @param  string $attribute condition column name
121
+	 * @return void
122
+	 */
123
+	public function delete($value, $attribute = 'id')
124
+	{
125
+		\DB::transaction(function () use ($value, $attribute) {
126
+			$this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function ($model) {
127
+				$model->delete();
128
+			});
129
+		});
130
+	}
131 131
     
132
-    /**
133
-     * Fetch records from the storage based on the given
134
-     * id.
135
-     *
136
-     * @param  integer $id
137
-     * @param  string[]   $relations
138
-     * @param  array   $columns
139
-     * @return object
140
-     */
141
-    public function find($id, $relations = [], $columns = ['*'])
142
-    {
143
-        return $this->model->with($relations)->find($id, $columns);
144
-    }
132
+	/**
133
+	 * Fetch records from the storage based on the given
134
+	 * id.
135
+	 *
136
+	 * @param  integer $id
137
+	 * @param  string[]   $relations
138
+	 * @param  array   $columns
139
+	 * @return object
140
+	 */
141
+	public function find($id, $relations = [], $columns = ['*'])
142
+	{
143
+		return $this->model->with($relations)->find($id, $columns);
144
+	}
145 145
     
146
-    /**
147
-     * Fetch records from the storage based on the given
148
-     * condition.
149
-     *
150
-     * @param  array   $conditions array of conditions
151
-     * @param  array   $relations
152
-     * @param  string  $sortBy
153
-     * @param  boolean $desc
154
-     * @param  array   $columns
155
-     * @return collection
156
-     */
157
-    public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
158
-    {
159
-        $conditions = $this->constructConditions($conditions, $this->model);
160
-        $sort       = $desc ? 'desc' : 'asc';
161
-        return $this->model->with($relations)->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns);
162
-    }
163
-
164
-    /**
165
-     * Fetch the first record from the storage based on the given
166
-     * condition.
167
-     *
168
-     * @param  array   $conditions array of conditions
169
-     * @param  array   $relations
170
-     * @param  array   $columns
171
-     * @return object
172
-     */
173
-    public function first($conditions, $relations = [], $columns = ['*'])
174
-    {
175
-        $conditions = $this->constructConditions($conditions, $this->model);
176
-        return $this->model->with($relations)->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->first($columns);
177
-    }
178
-
179
-    /**
180
-     * Return the deleted models in pages based on the given conditions.
181
-     *
182
-     * @param  array   $conditions array of conditions
183
-     * @param  integer $perPage
184
-     * @param  string  $sortBy
185
-     * @param  boolean $desc
186
-     * @param  array   $columns
187
-     * @return collection
188
-     */
189
-    public function deleted($conditions, $perPage = 15, $sortBy = 'created_at', $desc = 1, $columns = ['*'])
190
-    {
191
-        unset($conditions['page']);
192
-        unset($conditions['perPage']);
193
-        unset($conditions['sortBy']);
194
-        unset($conditions['sort']);
195
-        $conditions = $this->constructConditions($conditions, $this->model);
196
-        $sort       = $desc ? 'desc' : 'asc';
197
-        $model      = $this->model->onlyTrashed();
198
-
199
-        if (count($conditions['conditionValues'])) {
200
-            $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
201
-        }
202
-
203
-        return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns);
204
-    }
205
-
206
-    /**
207
-     * Restore the deleted model.
208
-     *
209
-     * @param  integer $id
210
-     * @return void
211
-     */
212
-    public function restore($id)
213
-    {
214
-        $model = $this->model->onlyTrashed()->find($id);
215
-
216
-        if (! $model) {
217
-            \Errors::notFound(class_basename($this->model).' with id : '.$id);
218
-        }
219
-
220
-        $model->restore();
221
-    }
222
-
223
-    /**
224
-     * Fill the model with the given data.
225
-     *
226
-     * @param   array  $data
227
-     *
228
-     * @return  object
229
-     */
230
-    public function prepareModel($data)
231
-    {
232
-        $modelClass = $this->model;
233
-
234
-        /**
235
-         * If the id is present in the data then select the model for updating,
236
-         * else create new model.
237
-         * @var array
238
-         */
239
-        $model = Arr::has($data, 'id') ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass;
240
-        if (! $model) {
241
-            \Errors::notFound(class_basename($modelClass).' with id : '.$data['id']);
242
-        }
243
-
244
-        /**
245
-         * Construct the model object with the given data,
246
-         * and if there is a relation add it to relations array,
247
-         * then save the model.
248
-         */
249
-        foreach ($data as $key => $value) {
250
-            if (array_search($key, $model->getFillable(), true) !== false) {
251
-                /**
252
-                 * If the attribute isn't a relation and prevent attributes not in the fillable.
253
-                 */
254
-                $model->$key = $value;
255
-            }
256
-        }
257
-
258
-        return $model;
259
-    }
146
+	/**
147
+	 * Fetch records from the storage based on the given
148
+	 * condition.
149
+	 *
150
+	 * @param  array   $conditions array of conditions
151
+	 * @param  array   $relations
152
+	 * @param  string  $sortBy
153
+	 * @param  boolean $desc
154
+	 * @param  array   $columns
155
+	 * @return collection
156
+	 */
157
+	public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
158
+	{
159
+		$conditions = $this->constructConditions($conditions, $this->model);
160
+		$sort       = $desc ? 'desc' : 'asc';
161
+		return $this->model->with($relations)->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns);
162
+	}
163
+
164
+	/**
165
+	 * Fetch the first record from the storage based on the given
166
+	 * condition.
167
+	 *
168
+	 * @param  array   $conditions array of conditions
169
+	 * @param  array   $relations
170
+	 * @param  array   $columns
171
+	 * @return object
172
+	 */
173
+	public function first($conditions, $relations = [], $columns = ['*'])
174
+	{
175
+		$conditions = $this->constructConditions($conditions, $this->model);
176
+		return $this->model->with($relations)->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->first($columns);
177
+	}
178
+
179
+	/**
180
+	 * Return the deleted models in pages based on the given conditions.
181
+	 *
182
+	 * @param  array   $conditions array of conditions
183
+	 * @param  integer $perPage
184
+	 * @param  string  $sortBy
185
+	 * @param  boolean $desc
186
+	 * @param  array   $columns
187
+	 * @return collection
188
+	 */
189
+	public function deleted($conditions, $perPage = 15, $sortBy = 'created_at', $desc = 1, $columns = ['*'])
190
+	{
191
+		unset($conditions['page']);
192
+		unset($conditions['perPage']);
193
+		unset($conditions['sortBy']);
194
+		unset($conditions['sort']);
195
+		$conditions = $this->constructConditions($conditions, $this->model);
196
+		$sort       = $desc ? 'desc' : 'asc';
197
+		$model      = $this->model->onlyTrashed();
198
+
199
+		if (count($conditions['conditionValues'])) {
200
+			$model->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
201
+		}
202
+
203
+		return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns);
204
+	}
205
+
206
+	/**
207
+	 * Restore the deleted model.
208
+	 *
209
+	 * @param  integer $id
210
+	 * @return void
211
+	 */
212
+	public function restore($id)
213
+	{
214
+		$model = $this->model->onlyTrashed()->find($id);
215
+
216
+		if (! $model) {
217
+			\Errors::notFound(class_basename($this->model).' with id : '.$id);
218
+		}
219
+
220
+		$model->restore();
221
+	}
222
+
223
+	/**
224
+	 * Fill the model with the given data.
225
+	 *
226
+	 * @param   array  $data
227
+	 *
228
+	 * @return  object
229
+	 */
230
+	public function prepareModel($data)
231
+	{
232
+		$modelClass = $this->model;
233
+
234
+		/**
235
+		 * If the id is present in the data then select the model for updating,
236
+		 * else create new model.
237
+		 * @var array
238
+		 */
239
+		$model = Arr::has($data, 'id') ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass;
240
+		if (! $model) {
241
+			\Errors::notFound(class_basename($modelClass).' with id : '.$data['id']);
242
+		}
243
+
244
+		/**
245
+		 * Construct the model object with the given data,
246
+		 * and if there is a relation add it to relations array,
247
+		 * then save the model.
248
+		 */
249
+		foreach ($data as $key => $value) {
250
+			if (array_search($key, $model->getFillable(), true) !== false) {
251
+				/**
252
+				 * If the attribute isn't a relation and prevent attributes not in the fillable.
253
+				 */
254
+				$model->$key = $value;
255
+			}
256
+		}
257
+
258
+		return $model;
259
+	}
260 260
     
261
-    /**
262
-     * Prepare related models based on the given data for the given model.
263
-     *
264
-     * @param   array  $data
265
-     * @param   object $model
266
-     *
267
-     * @return  array
268
-     */
269
-    public function prepareRelations($data, $model)
270
-    {
271
-        /**
272
-         * Init the relation array
273
-         *
274
-         * @var array
275
-         */
276
-        $relations = [];
277
-
278
-        /**
279
-         * Construct the model object with the given data,
280
-         * and if there is a relation add it to relations array,
281
-         * then save the model.
282
-         */
283
-        foreach ($data as $key => $value) {
284
-            /**
285
-             * If the attribute is a relation.
286
-             */
287
-            $relation = \Str::camel($key);
288
-            if (method_exists($model, $relation) && \Core::$relation()) {
289
-                /**
290
-                 * Check if the relation is a collection.
291
-                 */
292
-                if (class_basename($model->$relation) == 'Collection') {
293
-                    /**
294
-                     * If the relation has no value then marke the relation data
295
-                     * related to the model to be deleted.
296
-                     */
297
-                    if (! $value || ! count($value)) {
298
-                        $relations[$relation] = 'delete';
299
-                    }
300
-                }
301
-                if (is_array($value)) {
302
-                    /**
303
-                     * Loop through the relation data.
304
-                     */
305
-                    foreach ($value as $attr => $val) {
306
-                        /**
307
-                         * Get the relation model.
308
-                         */
309
-                        $relationBaseModel = \Core::$relation()->model;
310
-
311
-                        /**
312
-                         * Check if the relation is a collection.
313
-                         */
314
-                        if (class_basename($model->$relation) == 'Collection') {
315
-                            if (! is_array($val)) {
316
-                                $relationModel = $relationBaseModel->lockForUpdate()->find($val);
317
-                            } else {
318
-                                /**
319
-                                 * If the id is present in the data then select the relation model for updating,
320
-                                 * else create new model.
321
-                                 */
322
-                                $relationModel = Arr::has($val, 'id') ? $relationBaseModel->lockForUpdate()->find($val['id']) : new $relationBaseModel;
323
-                            }
324
-
325
-                            /**
326
-                             * If model doesn't exists.
327
-                             */
328
-                            if (! $relationModel) {
329
-                                \Errors::notFound(class_basename($relationBaseModel).' with id : '.$val['id']);
330
-                            }
331
-
332
-                            if (is_array($val)) {
333
-                                /**
334
-                                 * Loop through the relation attributes.
335
-                                 */
336
-                                foreach ($val as $attr => $val) {
337
-                                    /**
338
-                                     * Prevent the sub relations or attributes not in the fillable.
339
-                                     */
340
-                                    if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false) {
341
-                                        $relationModel->$attr = $val;
342
-                                    } elseif (gettype($val) !== 'object' && gettype($val) !== 'array' && $attr !== 'id') {
343
-                                        $extra[$attr] = $val;
344
-                                    }
345
-                                }
346
-                            }
347
-
348
-                            if (isset($extra)) {
349
-                                $relationModel->extra = $extra;
350
-                            }
351
-                            $relations[$relation][] = $relationModel;
352
-                        } else {
353
-                            /**
354
-                             * Prevent the sub relations.
355
-                             */
356
-                            if (gettype($val) !== 'object' && gettype($val) !== 'array') {
357
-                                /**
358
-                                 * If the id is present in the data then select the relation model for updating,
359
-                                 * else create new model.
360
-                                 */
361
-                                $relationModel = Arr::has($value, 'id') ? $relationBaseModel->lockForUpdate()->find($value['id']) : new $relationBaseModel;
362
-
363
-                                /**
364
-                                 * If model doesn't exists.
365
-                                 */
366
-                                if (! $relationModel) {
367
-                                    \Errors::notFound(class_basename($relationBaseModel).' with id : '.$value['id']);
368
-                                }
369
-
370
-                                foreach ($value as $relationAttribute => $relationValue) {
371
-                                    /**
372
-                                     * Prevent attributes not in the fillable.
373
-                                     */
374
-                                    if (array_search($relationAttribute, $relationModel->getFillable(), true) !== false) {
375
-                                        $relationModel->$relationAttribute = $relationValue;
376
-                                    }
377
-                                }
378
-
379
-                                $relations[$relation] = $relationModel;
380
-                            }
381
-                        }
382
-                    }
383
-                }
384
-            }
385
-        }
386
-
387
-        return $relations;
388
-    }
389
-
390
-    /**
391
-     * Save the model with related models.
392
-     *
393
-     * @param   object  $model
394
-     * @param   array   $relations
395
-     *
396
-     * @return  object
397
-     */
398
-    public function saveModel($model, $relations)
399
-    {
400
-
401
-        /**
402
-         * Loop through the relations array.
403
-         */
404
-        foreach ($relations as $key => $value) {
405
-            /**
406
-             * If the relation is marked for delete then delete it.
407
-             */
408
-            if ($value == 'delete' && $model->$key()->count()) {
409
-                $model->$key()->delete();
410
-            } elseif (gettype($value) == 'array') {
411
-                /**
412
-                 * Save the model.
413
-                 */
414
-                $model->save();
415
-                $ids = [];
416
-
417
-                /**
418
-                 * Loop through the relations.
419
-                 */
420
-                foreach ($value as $val) {
421
-                    switch (class_basename($model->$key())) {
422
-                        /**
423
-                         * If the relation is one to many then update it's foreign key with
424
-                         * the model id and save it then add its id to ids array to delete all
425
-                         * relations who's id isn't in the ids array.
426
-                         */
427
-                        case 'HasMany':
428
-                            $foreignKeyName       = $model->$key()->getForeignKeyName();
429
-                            $val->$foreignKeyName = $model->id;
430
-                            $val->save();
431
-                            $ids[] = $val->id;
432
-                            break;
433
-
434
-                        /**
435
-                         * If the relation is many to many then add it's id to the ids array to
436
-                         * attache these ids to the model.
437
-                         */
438
-                        case 'BelongsToMany':
439
-                            $extra = $val->extra;
440
-                            unset($val->extra);
441
-                            $val->save();
442
-                            $ids[$val->id] = $extra ?? [];
443
-                            break;
444
-                    }
445
-                }
446
-                switch (class_basename($model->$key())) {
447
-                    /**
448
-                     * If the relation is one to many then delete all
449
-                     * relations who's id isn't in the ids array.
450
-                     */
451
-                    case 'HasMany':
452
-                        $model->$key()->whereNotIn('id', $ids)->delete();
453
-                        break;
454
-
455
-                    /**
456
-                     * If the relation is many to many then
457
-                     * detach the previous data and attach
458
-                     * the ids array to the model.
459
-                     */
460
-                    case 'BelongsToMany':
461
-                        $model->$key()->detach();
462
-                        $model->$key()->attach($ids);
463
-                        break;
464
-                }
465
-            } else {
466
-                switch (class_basename($model->$key())) {
467
-                    /**
468
-                     * If the relation is one to one.
469
-                     */
470
-                    case 'HasOne':
471
-                        /**
472
-                         * Save the model.
473
-                         */
474
-                        $model->save();
475
-                        $foreignKeyName         = $model->$key()->getForeignKeyName();
476
-                        $value->$foreignKeyName = $model->id;
477
-                        $value->save();
478
-                        break;
479
-                    case 'BelongsTo':
480
-                        /**
481
-                         * Save the model.
482
-                         */
483
-                        $value->save();
484
-                        $model->$key()->associate($value);
485
-                        break;
486
-                }
487
-            }
488
-        }
489
-
490
-        /**
491
-         * Save the model.
492
-         */
493
-        $model->save();
494
-
495
-        return $model;
496
-    }
497
-
498
-    /**
499
-     * Build the conditions recursively for the retrieving methods.
500
-     * @param  array $conditions
501
-     * @return array
502
-     */
503
-    protected function constructConditions($conditions, $model)
504
-    {
505
-        $conditionString = '';
506
-        $conditionValues = [];
507
-        foreach ($conditions as $key => $value) {
508
-            if (Str::contains($key, '->')) {
509
-                $key = $this->wrapJsonSelector($key);
510
-            }
511
-
512
-            if ($key == 'and') {
513
-                $conditions       = $this->constructConditions($value, $model);
514
-                $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']).' {op} ';
515
-                $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
516
-            } elseif ($key == 'or') {
517
-                $conditions       = $this->constructConditions($value, $model);
518
-                $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']).' {op} ';
519
-                $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
520
-            } else {
521
-                if (is_array($value)) {
522
-                    $operator = $value['op'];
523
-                    if (strtolower($operator) == 'between') {
524
-                        $value1 = $value['val1'];
525
-                        $value2 = $value['val2'];
526
-                    } else {
527
-                        $value = Arr::get($value, 'val', '');
528
-                    }
529
-                } else {
530
-                    $operator = '=';
531
-                }
261
+	/**
262
+	 * Prepare related models based on the given data for the given model.
263
+	 *
264
+	 * @param   array  $data
265
+	 * @param   object $model
266
+	 *
267
+	 * @return  array
268
+	 */
269
+	public function prepareRelations($data, $model)
270
+	{
271
+		/**
272
+		 * Init the relation array
273
+		 *
274
+		 * @var array
275
+		 */
276
+		$relations = [];
277
+
278
+		/**
279
+		 * Construct the model object with the given data,
280
+		 * and if there is a relation add it to relations array,
281
+		 * then save the model.
282
+		 */
283
+		foreach ($data as $key => $value) {
284
+			/**
285
+			 * If the attribute is a relation.
286
+			 */
287
+			$relation = \Str::camel($key);
288
+			if (method_exists($model, $relation) && \Core::$relation()) {
289
+				/**
290
+				 * Check if the relation is a collection.
291
+				 */
292
+				if (class_basename($model->$relation) == 'Collection') {
293
+					/**
294
+					 * If the relation has no value then marke the relation data
295
+					 * related to the model to be deleted.
296
+					 */
297
+					if (! $value || ! count($value)) {
298
+						$relations[$relation] = 'delete';
299
+					}
300
+				}
301
+				if (is_array($value)) {
302
+					/**
303
+					 * Loop through the relation data.
304
+					 */
305
+					foreach ($value as $attr => $val) {
306
+						/**
307
+						 * Get the relation model.
308
+						 */
309
+						$relationBaseModel = \Core::$relation()->model;
310
+
311
+						/**
312
+						 * Check if the relation is a collection.
313
+						 */
314
+						if (class_basename($model->$relation) == 'Collection') {
315
+							if (! is_array($val)) {
316
+								$relationModel = $relationBaseModel->lockForUpdate()->find($val);
317
+							} else {
318
+								/**
319
+								 * If the id is present in the data then select the relation model for updating,
320
+								 * else create new model.
321
+								 */
322
+								$relationModel = Arr::has($val, 'id') ? $relationBaseModel->lockForUpdate()->find($val['id']) : new $relationBaseModel;
323
+							}
324
+
325
+							/**
326
+							 * If model doesn't exists.
327
+							 */
328
+							if (! $relationModel) {
329
+								\Errors::notFound(class_basename($relationBaseModel).' with id : '.$val['id']);
330
+							}
331
+
332
+							if (is_array($val)) {
333
+								/**
334
+								 * Loop through the relation attributes.
335
+								 */
336
+								foreach ($val as $attr => $val) {
337
+									/**
338
+									 * Prevent the sub relations or attributes not in the fillable.
339
+									 */
340
+									if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false) {
341
+										$relationModel->$attr = $val;
342
+									} elseif (gettype($val) !== 'object' && gettype($val) !== 'array' && $attr !== 'id') {
343
+										$extra[$attr] = $val;
344
+									}
345
+								}
346
+							}
347
+
348
+							if (isset($extra)) {
349
+								$relationModel->extra = $extra;
350
+							}
351
+							$relations[$relation][] = $relationModel;
352
+						} else {
353
+							/**
354
+							 * Prevent the sub relations.
355
+							 */
356
+							if (gettype($val) !== 'object' && gettype($val) !== 'array') {
357
+								/**
358
+								 * If the id is present in the data then select the relation model for updating,
359
+								 * else create new model.
360
+								 */
361
+								$relationModel = Arr::has($value, 'id') ? $relationBaseModel->lockForUpdate()->find($value['id']) : new $relationBaseModel;
362
+
363
+								/**
364
+								 * If model doesn't exists.
365
+								 */
366
+								if (! $relationModel) {
367
+									\Errors::notFound(class_basename($relationBaseModel).' with id : '.$value['id']);
368
+								}
369
+
370
+								foreach ($value as $relationAttribute => $relationValue) {
371
+									/**
372
+									 * Prevent attributes not in the fillable.
373
+									 */
374
+									if (array_search($relationAttribute, $relationModel->getFillable(), true) !== false) {
375
+										$relationModel->$relationAttribute = $relationValue;
376
+									}
377
+								}
378
+
379
+								$relations[$relation] = $relationModel;
380
+							}
381
+						}
382
+					}
383
+				}
384
+			}
385
+		}
386
+
387
+		return $relations;
388
+	}
389
+
390
+	/**
391
+	 * Save the model with related models.
392
+	 *
393
+	 * @param   object  $model
394
+	 * @param   array   $relations
395
+	 *
396
+	 * @return  object
397
+	 */
398
+	public function saveModel($model, $relations)
399
+	{
400
+
401
+		/**
402
+		 * Loop through the relations array.
403
+		 */
404
+		foreach ($relations as $key => $value) {
405
+			/**
406
+			 * If the relation is marked for delete then delete it.
407
+			 */
408
+			if ($value == 'delete' && $model->$key()->count()) {
409
+				$model->$key()->delete();
410
+			} elseif (gettype($value) == 'array') {
411
+				/**
412
+				 * Save the model.
413
+				 */
414
+				$model->save();
415
+				$ids = [];
416
+
417
+				/**
418
+				 * Loop through the relations.
419
+				 */
420
+				foreach ($value as $val) {
421
+					switch (class_basename($model->$key())) {
422
+						/**
423
+						 * If the relation is one to many then update it's foreign key with
424
+						 * the model id and save it then add its id to ids array to delete all
425
+						 * relations who's id isn't in the ids array.
426
+						 */
427
+						case 'HasMany':
428
+							$foreignKeyName       = $model->$key()->getForeignKeyName();
429
+							$val->$foreignKeyName = $model->id;
430
+							$val->save();
431
+							$ids[] = $val->id;
432
+							break;
433
+
434
+						/**
435
+						 * If the relation is many to many then add it's id to the ids array to
436
+						 * attache these ids to the model.
437
+						 */
438
+						case 'BelongsToMany':
439
+							$extra = $val->extra;
440
+							unset($val->extra);
441
+							$val->save();
442
+							$ids[$val->id] = $extra ?? [];
443
+							break;
444
+					}
445
+				}
446
+				switch (class_basename($model->$key())) {
447
+					/**
448
+					 * If the relation is one to many then delete all
449
+					 * relations who's id isn't in the ids array.
450
+					 */
451
+					case 'HasMany':
452
+						$model->$key()->whereNotIn('id', $ids)->delete();
453
+						break;
454
+
455
+					/**
456
+					 * If the relation is many to many then
457
+					 * detach the previous data and attach
458
+					 * the ids array to the model.
459
+					 */
460
+					case 'BelongsToMany':
461
+						$model->$key()->detach();
462
+						$model->$key()->attach($ids);
463
+						break;
464
+				}
465
+			} else {
466
+				switch (class_basename($model->$key())) {
467
+					/**
468
+					 * If the relation is one to one.
469
+					 */
470
+					case 'HasOne':
471
+						/**
472
+						 * Save the model.
473
+						 */
474
+						$model->save();
475
+						$foreignKeyName         = $model->$key()->getForeignKeyName();
476
+						$value->$foreignKeyName = $model->id;
477
+						$value->save();
478
+						break;
479
+					case 'BelongsTo':
480
+						/**
481
+						 * Save the model.
482
+						 */
483
+						$value->save();
484
+						$model->$key()->associate($value);
485
+						break;
486
+				}
487
+			}
488
+		}
489
+
490
+		/**
491
+		 * Save the model.
492
+		 */
493
+		$model->save();
494
+
495
+		return $model;
496
+	}
497
+
498
+	/**
499
+	 * Build the conditions recursively for the retrieving methods.
500
+	 * @param  array $conditions
501
+	 * @return array
502
+	 */
503
+	protected function constructConditions($conditions, $model)
504
+	{
505
+		$conditionString = '';
506
+		$conditionValues = [];
507
+		foreach ($conditions as $key => $value) {
508
+			if (Str::contains($key, '->')) {
509
+				$key = $this->wrapJsonSelector($key);
510
+			}
511
+
512
+			if ($key == 'and') {
513
+				$conditions       = $this->constructConditions($value, $model);
514
+				$conditionString .= str_replace('{op}', 'and', $conditions['conditionString']).' {op} ';
515
+				$conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
516
+			} elseif ($key == 'or') {
517
+				$conditions       = $this->constructConditions($value, $model);
518
+				$conditionString .= str_replace('{op}', 'or', $conditions['conditionString']).' {op} ';
519
+				$conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
520
+			} else {
521
+				if (is_array($value)) {
522
+					$operator = $value['op'];
523
+					if (strtolower($operator) == 'between') {
524
+						$value1 = $value['val1'];
525
+						$value2 = $value['val2'];
526
+					} else {
527
+						$value = Arr::get($value, 'val', '');
528
+					}
529
+				} else {
530
+					$operator = '=';
531
+				}
532 532
                 
533
-                if (strtolower($operator) == 'between') {
534
-                    $conditionString  .= $key.' >= ? and ';
535
-                    $conditionValues[] = $value1;
536
-
537
-                    $conditionString  .= $key.' <= ? {op} ';
538
-                    $conditionValues[] = $value2;
539
-                } elseif (strtolower($operator) == 'in') {
540
-                    $conditionValues  = array_merge($conditionValues, $value);
541
-                    $inBindingsString = rtrim(str_repeat('?,', count($value)), ',');
542
-                    $conditionString .= $key.' in ('.rtrim($inBindingsString, ',').') {op} ';
543
-                } elseif (strtolower($operator) == 'null') {
544
-                    $conditionString .= $key.' is null {op} ';
545
-                } elseif (strtolower($operator) == 'not null') {
546
-                    $conditionString .= $key.' is not null {op} ';
547
-                } elseif (strtolower($operator) == 'has') {
548
-                    $sql              = $model->withTrashed()->withoutGlobalScopes()->has($key)->toSql();
549
-                    $bindings         = $model->withTrashed()->withoutGlobalScopes()->has($key)->getBindings();
550
-                    $conditions       = $this->constructConditions($value, $model->$key()->getRelated());
551
-                    $conditionString .= substr(substr($sql, strpos($sql, 'exists')), 0, -1).' and '.$conditions['conditionString'].') {op} ';
552
-                    $conditionValues  = array_merge($conditionValues, $bindings);
553
-                    $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
554
-                } else {
555
-                    $conditionString  .= $key.' '.$operator.' ? {op} ';
556
-                    $conditionValues[] = $value;
557
-                }
558
-            }
559
-        }
560
-        $conditionString = '('.rtrim($conditionString, '{op} ').')';
561
-        return ['conditionString' => $conditionString, 'conditionValues' => $conditionValues];
562
-    }
563
-
564
-    /**
565
-     * Wrap the given JSON selector.
566
-     *
567
-     * @param  string  $value
568
-     * @return string
569
-     */
570
-    protected function wrapJsonSelector($value)
571
-    {
572
-        $removeLast = strpos($value, ')');
573
-        $value      = $removeLast === false ? $value : substr($value, 0, $removeLast);
574
-        $path       = explode('->', $value);
575
-        $field      = array_shift($path);
576
-        $result     = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function ($part) {
577
-            return '"'.$part.'"';
578
-        })->implode('.'));
533
+				if (strtolower($operator) == 'between') {
534
+					$conditionString  .= $key.' >= ? and ';
535
+					$conditionValues[] = $value1;
536
+
537
+					$conditionString  .= $key.' <= ? {op} ';
538
+					$conditionValues[] = $value2;
539
+				} elseif (strtolower($operator) == 'in') {
540
+					$conditionValues  = array_merge($conditionValues, $value);
541
+					$inBindingsString = rtrim(str_repeat('?,', count($value)), ',');
542
+					$conditionString .= $key.' in ('.rtrim($inBindingsString, ',').') {op} ';
543
+				} elseif (strtolower($operator) == 'null') {
544
+					$conditionString .= $key.' is null {op} ';
545
+				} elseif (strtolower($operator) == 'not null') {
546
+					$conditionString .= $key.' is not null {op} ';
547
+				} elseif (strtolower($operator) == 'has') {
548
+					$sql              = $model->withTrashed()->withoutGlobalScopes()->has($key)->toSql();
549
+					$bindings         = $model->withTrashed()->withoutGlobalScopes()->has($key)->getBindings();
550
+					$conditions       = $this->constructConditions($value, $model->$key()->getRelated());
551
+					$conditionString .= substr(substr($sql, strpos($sql, 'exists')), 0, -1).' and '.$conditions['conditionString'].') {op} ';
552
+					$conditionValues  = array_merge($conditionValues, $bindings);
553
+					$conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
554
+				} else {
555
+					$conditionString  .= $key.' '.$operator.' ? {op} ';
556
+					$conditionValues[] = $value;
557
+				}
558
+			}
559
+		}
560
+		$conditionString = '('.rtrim($conditionString, '{op} ').')';
561
+		return ['conditionString' => $conditionString, 'conditionValues' => $conditionValues];
562
+	}
563
+
564
+	/**
565
+	 * Wrap the given JSON selector.
566
+	 *
567
+	 * @param  string  $value
568
+	 * @return string
569
+	 */
570
+	protected function wrapJsonSelector($value)
571
+	{
572
+		$removeLast = strpos($value, ')');
573
+		$value      = $removeLast === false ? $value : substr($value, 0, $removeLast);
574
+		$path       = explode('->', $value);
575
+		$field      = array_shift($path);
576
+		$result     = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function ($part) {
577
+			return '"'.$part.'"';
578
+		})->implode('.'));
579 579
         
580
-        return $removeLast === false ? $result : $result.')';
581
-    }
580
+		return $removeLast === false ? $result : $result.')';
581
+	}
582 582
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      */
22 22
     public function __construct($model)
23 23
     {
24
-        $this->model  = $model;
24
+        $this->model = $model;
25 25
     }
26 26
 
27 27
     /**
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         $model      = false;
99 99
         $relations  = [];
100 100
 
101
-        \DB::transaction(function () use (&$model, &$relations, $data) {
101
+        \DB::transaction(function() use (&$model, &$relations, $data) {
102 102
             
103 103
             $model     = $this->prepareModel($data);
104 104
             $relations = $this->prepareRelations($data, $model);
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
      */
123 123
     public function delete($value, $attribute = 'id')
124 124
     {
125
-        \DB::transaction(function () use ($value, $attribute) {
126
-            $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function ($model) {
125
+        \DB::transaction(function() use ($value, $attribute) {
126
+            $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function($model) {
127 127
                 $model->delete();
128 128
             });
129 129
         });
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
     {
214 214
         $model = $this->model->onlyTrashed()->find($id);
215 215
 
216
-        if (! $model) {
216
+        if ( ! $model) {
217 217
             \Errors::notFound(class_basename($this->model).' with id : '.$id);
218 218
         }
219 219
 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
          * @var array
238 238
          */
239 239
         $model = Arr::has($data, 'id') ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass;
240
-        if (! $model) {
240
+        if ( ! $model) {
241 241
             \Errors::notFound(class_basename($modelClass).' with id : '.$data['id']);
242 242
         }
243 243
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
                      * If the relation has no value then marke the relation data
295 295
                      * related to the model to be deleted.
296 296
                      */
297
-                    if (! $value || ! count($value)) {
297
+                    if ( ! $value || ! count($value)) {
298 298
                         $relations[$relation] = 'delete';
299 299
                     }
300 300
                 }
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
                          * Check if the relation is a collection.
313 313
                          */
314 314
                         if (class_basename($model->$relation) == 'Collection') {
315
-                            if (! is_array($val)) {
315
+                            if ( ! is_array($val)) {
316 316
                                 $relationModel = $relationBaseModel->lockForUpdate()->find($val);
317 317
                             } else {
318 318
                                 /**
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
                             /**
326 326
                              * If model doesn't exists.
327 327
                              */
328
-                            if (! $relationModel) {
328
+                            if ( ! $relationModel) {
329 329
                                 \Errors::notFound(class_basename($relationBaseModel).' with id : '.$val['id']);
330 330
                             }
331 331
 
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
                                 /**
364 364
                                  * If model doesn't exists.
365 365
                                  */
366
-                                if (! $relationModel) {
366
+                                if ( ! $relationModel) {
367 367
                                     \Errors::notFound(class_basename($relationBaseModel).' with id : '.$value['id']);
368 368
                                 }
369 369
 
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
         $value      = $removeLast === false ? $value : substr($value, 0, $removeLast);
574 574
         $path       = explode('->', $value);
575 575
         $field      = array_shift($path);
576
-        $result     = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function ($part) {
576
+        $result     = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function($part) {
577 577
             return '"'.$part.'"';
578 578
         })->implode('.'));
579 579
         
Please login to merge, or discard this patch.
src/Modules/Core/BaseClasses/BaseService.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      *
53 53
      * @param  array   $relations
54 54
      * @param  string  $sortBy
55
-     * @param  boolean $desc
55
+     * @param  integer $desc
56 56
      * @param  array   $columns
57 57
      * @return collection
58 58
      */
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      * @param  integer $perPage
68 68
      * @param  array   $relations
69 69
      * @param  string  $sortBy
70
-     * @param  boolean $desc
70
+     * @param  integer $desc
71 71
      * @param  array   $columns
72 72
      * @return collection
73 73
      */
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      * @param  integer $perPage
85 85
      * @param  array   $relations
86 86
      * @param  string  $sortBy
87
-     * @param  boolean $desc
87
+     * @param  integer $desc
88 88
      * @param  array   $columns
89 89
      * @return collection
90 90
      */
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      * @param  array   $conditions array of conditions
139 139
      * @param  array   $relations
140 140
      * @param  string  $sortBy
141
-     * @param  boolean $desc
141
+     * @param  integer $desc
142 142
      * @param  array   $columns
143 143
      * @return collection
144 144
      */
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
      * @param  array   $conditions array of conditions
168 168
      * @param  integer $perPage
169 169
      * @param  string  $sortBy
170
-     * @param  boolean $desc
170
+     * @param  integer $desc
171 171
      * @param  array   $columns
172 172
      * @return collection
173 173
      */
Please login to merge, or discard this patch.
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -6,223 +6,223 @@
 block discarded – undo
6 6
 
7 7
 abstract class BaseService implements BaseServiceInterface
8 8
 {
9
-    /**
10
-     * @var object
11
-     */
12
-    public $repo;
9
+	/**
10
+	 * @var object
11
+	 */
12
+	public $repo;
13 13
 
14
-    /**
15
-     * Init new object.
16
-     *
17
-     * @param   mixed  $repo
18
-     * @return  void
19
-     */
20
-    public function __construct($repo)
21
-    {
22
-        $this->repo = $repo;
23
-    }
14
+	/**
15
+	 * Init new object.
16
+	 *
17
+	 * @param   mixed  $repo
18
+	 * @return  void
19
+	 */
20
+	public function __construct($repo)
21
+	{
22
+		$this->repo = $repo;
23
+	}
24 24
 
25
-    /**
26
-     * Fetch records with relations based on the given params.
27
-     *
28
-     * @param   array   $relations
29
-     * @param   array   $conditions
30
-     * @param   integer $perPage
31
-     * @param   string  $sortBy
32
-     * @param   boolean $desc
33
-     * @param   boolean $trashed
34
-     * @return collection
35
-     */
36
-    public function list($relations = [], $conditions = false, $perPage = 15, $sortBy = 'created_at', $desc = true, $trashed = false)
37
-    {
38
-        $translatable = $this->repo->model->translatable ?? [];
39
-        $filters = $this->constructFilters($conditions);
40
-        $sortBy = in_array($sortBy, $translatable) ? $sortBy . '->' . \Session::get('locale') : $sortBy;
25
+	/**
26
+	 * Fetch records with relations based on the given params.
27
+	 *
28
+	 * @param   array   $relations
29
+	 * @param   array   $conditions
30
+	 * @param   integer $perPage
31
+	 * @param   string  $sortBy
32
+	 * @param   boolean $desc
33
+	 * @param   boolean $trashed
34
+	 * @return collection
35
+	 */
36
+	public function list($relations = [], $conditions = false, $perPage = 15, $sortBy = 'created_at', $desc = true, $trashed = false)
37
+	{
38
+		$translatable = $this->repo->model->translatable ?? [];
39
+		$filters = $this->constructFilters($conditions);
40
+		$sortBy = in_array($sortBy, $translatable) ? $sortBy . '->' . \Session::get('locale') : $sortBy;
41 41
 
42
-        if ($trashed) {
43
-            return $this->deleted(['and' => $filters], $perPage ?? 15, $sortBy ?? 'created_at', $desc ?? true);
44
-        }
42
+		if ($trashed) {
43
+			return $this->deleted(['and' => $filters], $perPage ?? 15, $sortBy ?? 'created_at', $desc ?? true);
44
+		}
45 45
         
46
-        if (count($filters)) {
47
-            return $this->paginateBy(['and' => $filters], $perPage ?? 15, $relations, $sortBy ?? 'created_at', $desc ?? true);
48
-        }
46
+		if (count($filters)) {
47
+			return $this->paginateBy(['and' => $filters], $perPage ?? 15, $relations, $sortBy ?? 'created_at', $desc ?? true);
48
+		}
49 49
 
50
-        return $this->paginate($perPage ?? 15, $relations, $sortBy ?? 'created_at', $desc ?? true);
51
-    }
50
+		return $this->paginate($perPage ?? 15, $relations, $sortBy ?? 'created_at', $desc ?? true);
51
+	}
52 52
 
53
-    /**
54
-     * Fetch all records with relations from the storage.
55
-     *
56
-     * @param  array   $relations
57
-     * @param  string  $sortBy
58
-     * @param  boolean $desc
59
-     * @param  array   $columns
60
-     * @return collection
61
-     */
62
-    public function all($relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
63
-    {
64
-        return $this->repo->all($relations, $sortBy, $desc, $columns);
65
-    }
53
+	/**
54
+	 * Fetch all records with relations from the storage.
55
+	 *
56
+	 * @param  array   $relations
57
+	 * @param  string  $sortBy
58
+	 * @param  boolean $desc
59
+	 * @param  array   $columns
60
+	 * @return collection
61
+	 */
62
+	public function all($relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
63
+	{
64
+		return $this->repo->all($relations, $sortBy, $desc, $columns);
65
+	}
66 66
     
67
-    /**
68
-     * Fetch all records with relations from storage in pages.
69
-     *
70
-     * @param  integer $perPage
71
-     * @param  array   $relations
72
-     * @param  string  $sortBy
73
-     * @param  boolean $desc
74
-     * @param  array   $columns
75
-     * @return collection
76
-     */
77
-    public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
78
-    {
79
-        return $this->repo->paginate($perPage, $relations, $sortBy, $desc, $columns);
80
-    }
67
+	/**
68
+	 * Fetch all records with relations from storage in pages.
69
+	 *
70
+	 * @param  integer $perPage
71
+	 * @param  array   $relations
72
+	 * @param  string  $sortBy
73
+	 * @param  boolean $desc
74
+	 * @param  array   $columns
75
+	 * @return collection
76
+	 */
77
+	public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
78
+	{
79
+		return $this->repo->paginate($perPage, $relations, $sortBy, $desc, $columns);
80
+	}
81 81
 
82
-    /**
83
-     * Fetch all records with relations based on
84
-     * the given condition from storage in pages.
85
-     *
86
-     * @param  array   $conditions array of conditions
87
-     * @param  integer $perPage
88
-     * @param  array   $relations
89
-     * @param  string  $sortBy
90
-     * @param  boolean $desc
91
-     * @param  array   $columns
92
-     * @return collection
93
-     */
94
-    public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
95
-    {
96
-        return $this->repo->paginateBy($conditions, $perPage, $relations, $sortBy, $desc, $columns);
97
-    }
82
+	/**
83
+	 * Fetch all records with relations based on
84
+	 * the given condition from storage in pages.
85
+	 *
86
+	 * @param  array   $conditions array of conditions
87
+	 * @param  integer $perPage
88
+	 * @param  array   $relations
89
+	 * @param  string  $sortBy
90
+	 * @param  boolean $desc
91
+	 * @param  array   $columns
92
+	 * @return collection
93
+	 */
94
+	public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
95
+	{
96
+		return $this->repo->paginateBy($conditions, $perPage, $relations, $sortBy, $desc, $columns);
97
+	}
98 98
     
99
-    /**
100
-     * Save the given model to the storage.
101
-     *
102
-     * @param  array $data
103
-     * @return mixed
104
-     */
105
-    public function save(array $data)
106
-    {
107
-        return $this->repo->save($data);
108
-    }
99
+	/**
100
+	 * Save the given model to the storage.
101
+	 *
102
+	 * @param  array $data
103
+	 * @return mixed
104
+	 */
105
+	public function save(array $data)
106
+	{
107
+		return $this->repo->save($data);
108
+	}
109 109
 
110
-    /**
111
-     * Delete record from the storage based on the given
112
-     * condition.
113
-     *
114
-     * @param  var $value condition value
115
-     * @param  string $attribute condition column name
116
-     * @return void
117
-     */
118
-    public function delete($value, $attribute = 'id')
119
-    {
120
-        return $this->repo->delete($value, $attribute);
121
-    }
110
+	/**
111
+	 * Delete record from the storage based on the given
112
+	 * condition.
113
+	 *
114
+	 * @param  var $value condition value
115
+	 * @param  string $attribute condition column name
116
+	 * @return void
117
+	 */
118
+	public function delete($value, $attribute = 'id')
119
+	{
120
+		return $this->repo->delete($value, $attribute);
121
+	}
122 122
     
123
-    /**
124
-     * Fetch records from the storage based on the given
125
-     * id.
126
-     *
127
-     * @param  integer $id
128
-     * @param  array   $relations
129
-     * @param  array   $columns
130
-     * @return object
131
-     */
132
-    public function find($id, $relations = [], $columns = ['*'])
133
-    {
134
-        return $this->repo->find($id, $relations, $columns);
135
-    }
123
+	/**
124
+	 * Fetch records from the storage based on the given
125
+	 * id.
126
+	 *
127
+	 * @param  integer $id
128
+	 * @param  array   $relations
129
+	 * @param  array   $columns
130
+	 * @return object
131
+	 */
132
+	public function find($id, $relations = [], $columns = ['*'])
133
+	{
134
+		return $this->repo->find($id, $relations, $columns);
135
+	}
136 136
     
137
-    /**
138
-     * Fetch records from the storage based on the given
139
-     * condition.
140
-     *
141
-     * @param  array   $conditions array of conditions
142
-     * @param  array   $relations
143
-     * @param  string  $sortBy
144
-     * @param  boolean $desc
145
-     * @param  array   $columns
146
-     * @return collection
147
-     */
148
-    public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
149
-    {
150
-        return $this->repo->findBy($conditions, $relations, $sortBy, $desc, $columns);
151
-    }
137
+	/**
138
+	 * Fetch records from the storage based on the given
139
+	 * condition.
140
+	 *
141
+	 * @param  array   $conditions array of conditions
142
+	 * @param  array   $relations
143
+	 * @param  string  $sortBy
144
+	 * @param  boolean $desc
145
+	 * @param  array   $columns
146
+	 * @return collection
147
+	 */
148
+	public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
149
+	{
150
+		return $this->repo->findBy($conditions, $relations, $sortBy, $desc, $columns);
151
+	}
152 152
 
153
-    /**
154
-     * Fetch the first record from the storage based on the given
155
-     * condition.
156
-     *
157
-     * @param  array   $conditions array of conditions
158
-     * @param  array   $relations
159
-     * @param  array   $columns
160
-     * @return object
161
-     */
162
-    public function first($conditions, $relations = [], $columns = ['*'])
163
-    {
164
-        return $this->repo->first($conditions, $relations, $columns);
165
-    }
153
+	/**
154
+	 * Fetch the first record from the storage based on the given
155
+	 * condition.
156
+	 *
157
+	 * @param  array   $conditions array of conditions
158
+	 * @param  array   $relations
159
+	 * @param  array   $columns
160
+	 * @return object
161
+	 */
162
+	public function first($conditions, $relations = [], $columns = ['*'])
163
+	{
164
+		return $this->repo->first($conditions, $relations, $columns);
165
+	}
166 166
 
167
-    /**
168
-     * Return the deleted models in pages based on the given conditions.
169
-     *
170
-     * @param  array   $conditions array of conditions
171
-     * @param  integer $perPage
172
-     * @param  string  $sortBy
173
-     * @param  boolean $desc
174
-     * @param  array   $columns
175
-     * @return collection
176
-     */
177
-    public function deleted($conditions, $perPage = 15, $sortBy = 'created_at', $desc = 1, $columns = ['*'])
178
-    {
179
-        return $this->repo->deleted($conditions, $perPage, $sortBy, $desc, $columns);
180
-    }
167
+	/**
168
+	 * Return the deleted models in pages based on the given conditions.
169
+	 *
170
+	 * @param  array   $conditions array of conditions
171
+	 * @param  integer $perPage
172
+	 * @param  string  $sortBy
173
+	 * @param  boolean $desc
174
+	 * @param  array   $columns
175
+	 * @return collection
176
+	 */
177
+	public function deleted($conditions, $perPage = 15, $sortBy = 'created_at', $desc = 1, $columns = ['*'])
178
+	{
179
+		return $this->repo->deleted($conditions, $perPage, $sortBy, $desc, $columns);
180
+	}
181 181
 
182
-    /**
183
-     * Restore the deleted model.
184
-     *
185
-     * @param  integer $id
186
-     * @return void
187
-     */
188
-    public function restore($id)
189
-    {
190
-        return $this->repo->restore($id);
191
-    }
182
+	/**
183
+	 * Restore the deleted model.
184
+	 *
185
+	 * @param  integer $id
186
+	 * @return void
187
+	 */
188
+	public function restore($id)
189
+	{
190
+		return $this->repo->restore($id);
191
+	}
192 192
 
193
-    /**
194
-     * Prepare filters for repo.
195
-     *
196
-     * @param  array   $conditions
197
-     * @return array
198
-     */
199
-    public function constructFilters($conditions)
200
-    {
201
-        $filters = [];
202
-        $translatable = $this->repo->model->translatable ?? [];
203
-        foreach ($conditions as $key => $value) {
204
-            if ((in_array($key, $this->repo->model->fillable ?? []) || method_exists($this->repo->model, $key) || in_array($key, ['or', 'and'])) && $key !== 'trashed') {
205
-                $key = in_array($key, $translatable) ? $key . '->' . (\Session::get('locale') == 'all' ? 'en' : \Session::get('locale')) : $key;
206
-                if (filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) !== null && strpos($key, '_id') === false && ! is_null($value)) {
207
-                    $filters[$key] = filter_var($value, FILTER_VALIDATE_BOOLEAN);
208
-                } elseif (! is_array($value) && strpos($key, '_id')) {
209
-                    $filters[$key] = [
210
-                        'op' => 'in',
211
-                        'val' => explode(',', $value)
212
-                    ];
213
-                } elseif (is_array($value)) {
214
-                    $filters[$key] = $value;
215
-                } elseif($value) {
216
-                    $key = 'LOWER(' . $key . ')';
217
-                    $value = strtolower($value);
218
-                    $filters[$key] = [
219
-                        'op' => 'like',
220
-                        'val' => '%' . $value . '%'
221
-                    ];
222
-                }
223
-            }
224
-        }
193
+	/**
194
+	 * Prepare filters for repo.
195
+	 *
196
+	 * @param  array   $conditions
197
+	 * @return array
198
+	 */
199
+	public function constructFilters($conditions)
200
+	{
201
+		$filters = [];
202
+		$translatable = $this->repo->model->translatable ?? [];
203
+		foreach ($conditions as $key => $value) {
204
+			if ((in_array($key, $this->repo->model->fillable ?? []) || method_exists($this->repo->model, $key) || in_array($key, ['or', 'and'])) && $key !== 'trashed') {
205
+				$key = in_array($key, $translatable) ? $key . '->' . (\Session::get('locale') == 'all' ? 'en' : \Session::get('locale')) : $key;
206
+				if (filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) !== null && strpos($key, '_id') === false && ! is_null($value)) {
207
+					$filters[$key] = filter_var($value, FILTER_VALIDATE_BOOLEAN);
208
+				} elseif (! is_array($value) && strpos($key, '_id')) {
209
+					$filters[$key] = [
210
+						'op' => 'in',
211
+						'val' => explode(',', $value)
212
+					];
213
+				} elseif (is_array($value)) {
214
+					$filters[$key] = $value;
215
+				} elseif($value) {
216
+					$key = 'LOWER(' . $key . ')';
217
+					$value = strtolower($value);
218
+					$filters[$key] = [
219
+						'op' => 'like',
220
+						'val' => '%' . $value . '%'
221
+					];
222
+				}
223
+			}
224
+		}
225 225
 
226
-        return $filters;
227
-    }
226
+		return $filters;
227
+	}
228 228
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     {
38 38
         $translatable = $this->repo->model->translatable ?? [];
39 39
         $filters = $this->constructFilters($conditions);
40
-        $sortBy = in_array($sortBy, $translatable) ? $sortBy . '->' . \Session::get('locale') : $sortBy;
40
+        $sortBy = in_array($sortBy, $translatable) ? $sortBy.'->'.\Session::get('locale') : $sortBy;
41 41
 
42 42
         if ($trashed) {
43 43
             return $this->deleted(['and' => $filters], $perPage ?? 15, $sortBy ?? 'created_at', $desc ?? true);
@@ -202,22 +202,22 @@  discard block
 block discarded – undo
202 202
         $translatable = $this->repo->model->translatable ?? [];
203 203
         foreach ($conditions as $key => $value) {
204 204
             if ((in_array($key, $this->repo->model->fillable ?? []) || method_exists($this->repo->model, $key) || in_array($key, ['or', 'and'])) && $key !== 'trashed') {
205
-                $key = in_array($key, $translatable) ? $key . '->' . (\Session::get('locale') == 'all' ? 'en' : \Session::get('locale')) : $key;
205
+                $key = in_array($key, $translatable) ? $key.'->'.(\Session::get('locale') == 'all' ? 'en' : \Session::get('locale')) : $key;
206 206
                 if (filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) !== null && strpos($key, '_id') === false && ! is_null($value)) {
207 207
                     $filters[$key] = filter_var($value, FILTER_VALIDATE_BOOLEAN);
208
-                } elseif (! is_array($value) && strpos($key, '_id')) {
208
+                } elseif ( ! is_array($value) && strpos($key, '_id')) {
209 209
                     $filters[$key] = [
210 210
                         'op' => 'in',
211 211
                         'val' => explode(',', $value)
212 212
                     ];
213 213
                 } elseif (is_array($value)) {
214 214
                     $filters[$key] = $value;
215
-                } elseif($value) {
216
-                    $key = 'LOWER(' . $key . ')';
215
+                } elseif ($value) {
216
+                    $key = 'LOWER('.$key.')';
217 217
                     $value = strtolower($value);
218 218
                     $filters[$key] = [
219 219
                         'op' => 'like',
220
-                        'val' => '%' . $value . '%'
220
+                        'val' => '%'.$value.'%'
221 221
                     ];
222 222
                 }
223 223
             }
Please login to merge, or discard this patch.
src/Modules/Core/Interfaces/BaseRepositoryInterface.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -2,93 +2,93 @@
 block discarded – undo
2 2
 
3 3
 interface BaseRepositoryInterface
4 4
 {
5
-    /**
6
-     * Fetch all records with relations from the storage.
7
-     *
8
-     * @param  array  $relations
9
-     * @param  array  $sortBy
10
-     * @param  array  $desc
11
-     * @param  array  $columns
12
-     * @return collection
13
-     */
14
-    public function all($relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']);
5
+	/**
6
+	 * Fetch all records with relations from the storage.
7
+	 *
8
+	 * @param  array  $relations
9
+	 * @param  array  $sortBy
10
+	 * @param  array  $desc
11
+	 * @param  array  $columns
12
+	 * @return collection
13
+	 */
14
+	public function all($relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']);
15 15
 
16
-    /**
17
-     * Fetch all records with relations from storage in pages.
18
-     *
19
-     * @param  integer $perPage
20
-     * @param  array   $relations
21
-     * @param  array   $sortBy
22
-     * @param  array   $desc
23
-     * @param  array   $columns
24
-     * @return collection
25
-     */
26
-    public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']);
16
+	/**
17
+	 * Fetch all records with relations from storage in pages.
18
+	 *
19
+	 * @param  integer $perPage
20
+	 * @param  array   $relations
21
+	 * @param  array   $sortBy
22
+	 * @param  array   $desc
23
+	 * @param  array   $columns
24
+	 * @return collection
25
+	 */
26
+	public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']);
27 27
     
28
-    /**
29
-     * Fetch all records with relations based on
30
-     * the given condition from storage in pages.
31
-     *
32
-     * @param  array   $conditions array of conditions
33
-     * @param  integer $perPage
34
-     * @param  array   $relations
35
-     * @param  array   $sortBy
36
-     * @param  array   $desc
37
-     * @param  array   $columns
38
-     * @return collection
39
-     */
40
-    public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']);
28
+	/**
29
+	 * Fetch all records with relations based on
30
+	 * the given condition from storage in pages.
31
+	 *
32
+	 * @param  array   $conditions array of conditions
33
+	 * @param  integer $perPage
34
+	 * @param  array   $relations
35
+	 * @param  array   $sortBy
36
+	 * @param  array   $desc
37
+	 * @param  array   $columns
38
+	 * @return collection
39
+	 */
40
+	public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']);
41 41
 
42
-     /**
43
-      * Save the given model/models to the storage.
44
-      *
45
-      * @param  array   $data
46
-      * @return mixed
47
-      */
48
-    public function save(array $data);
42
+	 /**
43
+	  * Save the given model/models to the storage.
44
+	  *
45
+	  * @param  array   $data
46
+	  * @return mixed
47
+	  */
48
+	public function save(array $data);
49 49
 
50
-    /**
51
-     * Delete record from the storage based on the given
52
-     * condition.
53
-     *
54
-     * @param  var     $value condition value
55
-     * @param  string  $attribute condition column name
56
-     * @return integer affected rows
57
-     */
58
-    public function delete($value, $attribute = 'id');
50
+	/**
51
+	 * Delete record from the storage based on the given
52
+	 * condition.
53
+	 *
54
+	 * @param  var     $value condition value
55
+	 * @param  string  $attribute condition column name
56
+	 * @return integer affected rows
57
+	 */
58
+	public function delete($value, $attribute = 'id');
59 59
     
60
-    /**
61
-     * Fetch records from the storage based on the given
62
-     * id.
63
-     *
64
-     * @param  integer $id
65
-     * @param  array   $relations
66
-     * @param  array   $columns
67
-     * @return object
68
-     */
69
-    public function find($id, $relations = [], $columns = ['*']);
60
+	/**
61
+	 * Fetch records from the storage based on the given
62
+	 * id.
63
+	 *
64
+	 * @param  integer $id
65
+	 * @param  array   $relations
66
+	 * @param  array   $columns
67
+	 * @return object
68
+	 */
69
+	public function find($id, $relations = [], $columns = ['*']);
70 70
     
71
-    /**
72
-     * Fetch records from the storage based on the given
73
-     * condition.
74
-     *
75
-     * @param  array   $conditions array of conditions
76
-     * @param  array   $relations
77
-     * @param  array   $sortBy
78
-     * @param  array   $desc
79
-     * @param  array   $columns
80
-     * @return collection
81
-     */
82
-    public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']);
71
+	/**
72
+	 * Fetch records from the storage based on the given
73
+	 * condition.
74
+	 *
75
+	 * @param  array   $conditions array of conditions
76
+	 * @param  array   $relations
77
+	 * @param  array   $sortBy
78
+	 * @param  array   $desc
79
+	 * @param  array   $columns
80
+	 * @return collection
81
+	 */
82
+	public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']);
83 83
 
84
-    /**
85
-     * Fetch the first record fro the storage based on the given
86
-     * condition.
87
-     *
88
-     * @param  array   $conditions array of conditions
89
-     * @param  array   $relations
90
-     * @param  array   $columns
91
-     * @return object
92
-     */
93
-    public function first($conditions, $relations = [], $columns = ['*']);
84
+	/**
85
+	 * Fetch the first record fro the storage based on the given
86
+	 * condition.
87
+	 *
88
+	 * @param  array   $conditions array of conditions
89
+	 * @param  array   $relations
90
+	 * @param  array   $columns
91
+	 * @return object
92
+	 */
93
+	public function first($conditions, $relations = [], $columns = ['*']);
94 94
 }
Please login to merge, or discard this patch.
src/Modules/Core/Interfaces/BaseServiceInterface.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -2,93 +2,93 @@
 block discarded – undo
2 2
 
3 3
 interface BaseServiceInterface
4 4
 {
5
-    /**
6
-     * Fetch all records with relations from the storage.
7
-     *
8
-     * @param  array  $relations
9
-     * @param  array  $sortBy
10
-     * @param  array  $desc
11
-     * @param  array  $columns
12
-     * @return collection
13
-     */
14
-    public function all($relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']);
5
+	/**
6
+	 * Fetch all records with relations from the storage.
7
+	 *
8
+	 * @param  array  $relations
9
+	 * @param  array  $sortBy
10
+	 * @param  array  $desc
11
+	 * @param  array  $columns
12
+	 * @return collection
13
+	 */
14
+	public function all($relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']);
15 15
 
16
-    /**
17
-     * Fetch all records with relations from storage in pages.
18
-     *
19
-     * @param  integer $perPage
20
-     * @param  array   $relations
21
-     * @param  array   $sortBy
22
-     * @param  array   $desc
23
-     * @param  array   $columns
24
-     * @return collection
25
-     */
26
-    public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']);
16
+	/**
17
+	 * Fetch all records with relations from storage in pages.
18
+	 *
19
+	 * @param  integer $perPage
20
+	 * @param  array   $relations
21
+	 * @param  array   $sortBy
22
+	 * @param  array   $desc
23
+	 * @param  array   $columns
24
+	 * @return collection
25
+	 */
26
+	public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']);
27 27
     
28
-    /**
29
-     * Fetch all records with relations based on
30
-     * the given condition from storage in pages.
31
-     *
32
-     * @param  array   $conditions array of conditions
33
-     * @param  integer $perPage
34
-     * @param  array   $relations
35
-     * @param  array   $sortBy
36
-     * @param  array   $desc
37
-     * @param  array   $columns
38
-     * @return collection
39
-     */
40
-    public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']);
28
+	/**
29
+	 * Fetch all records with relations based on
30
+	 * the given condition from storage in pages.
31
+	 *
32
+	 * @param  array   $conditions array of conditions
33
+	 * @param  integer $perPage
34
+	 * @param  array   $relations
35
+	 * @param  array   $sortBy
36
+	 * @param  array   $desc
37
+	 * @param  array   $columns
38
+	 * @return collection
39
+	 */
40
+	public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']);
41 41
 
42
-     /**
43
-      * Save the given model/models to the storage.
44
-      *
45
-      * @param  array   $data
46
-      * @return mixed
47
-      */
48
-    public function save(array $data);
42
+	 /**
43
+	  * Save the given model/models to the storage.
44
+	  *
45
+	  * @param  array   $data
46
+	  * @return mixed
47
+	  */
48
+	public function save(array $data);
49 49
 
50
-    /**
51
-     * Delete record from the storage based on the given
52
-     * condition.
53
-     *
54
-     * @param  var     $value condition value
55
-     * @param  string  $attribute condition column name
56
-     * @return integer affected rows
57
-     */
58
-    public function delete($value, $attribute = 'id');
50
+	/**
51
+	 * Delete record from the storage based on the given
52
+	 * condition.
53
+	 *
54
+	 * @param  var     $value condition value
55
+	 * @param  string  $attribute condition column name
56
+	 * @return integer affected rows
57
+	 */
58
+	public function delete($value, $attribute = 'id');
59 59
     
60
-    /**
61
-     * Fetch records from the storage based on the given
62
-     * id.
63
-     *
64
-     * @param  integer $id
65
-     * @param  array   $relations
66
-     * @param  array   $columns
67
-     * @return object
68
-     */
69
-    public function find($id, $relations = [], $columns = ['*']);
60
+	/**
61
+	 * Fetch records from the storage based on the given
62
+	 * id.
63
+	 *
64
+	 * @param  integer $id
65
+	 * @param  array   $relations
66
+	 * @param  array   $columns
67
+	 * @return object
68
+	 */
69
+	public function find($id, $relations = [], $columns = ['*']);
70 70
     
71
-    /**
72
-     * Fetch records from the storage based on the given
73
-     * condition.
74
-     *
75
-     * @param  array   $conditions array of conditions
76
-     * @param  array   $relations
77
-     * @param  array   $sortBy
78
-     * @param  array   $desc
79
-     * @param  array   $columns
80
-     * @return collection
81
-     */
82
-    public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']);
71
+	/**
72
+	 * Fetch records from the storage based on the given
73
+	 * condition.
74
+	 *
75
+	 * @param  array   $conditions array of conditions
76
+	 * @param  array   $relations
77
+	 * @param  array   $sortBy
78
+	 * @param  array   $desc
79
+	 * @param  array   $columns
80
+	 * @return collection
81
+	 */
82
+	public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 0, $columns = ['*']);
83 83
 
84
-    /**
85
-     * Fetch the first record fro the storage based on the given
86
-     * condition.
87
-     *
88
-     * @param  array   $conditions array of conditions
89
-     * @param  array   $relations
90
-     * @param  array   $columns
91
-     * @return object
92
-     */
93
-    public function first($conditions, $relations = [], $columns = ['*']);
84
+	/**
85
+	 * Fetch the first record fro the storage based on the given
86
+	 * condition.
87
+	 *
88
+	 * @param  array   $conditions array of conditions
89
+	 * @param  array   $relations
90
+	 * @param  array   $columns
91
+	 * @return object
92
+	 */
93
+	public function first($conditions, $relations = [], $columns = ['*']);
94 94
 }
Please login to merge, or discard this patch.
src/Modules/Users/Repositories/UserRepository.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 namespace App\Modules\Users\Repositories;
4 4
 
5 5
 use App\Modules\Core\BaseClasses\BaseRepository;
6
-use Illuminate\Support\Arr;
7 6
 use App\Modules\Users\AclUser;
8 7
 
9 8
 class UserRepository extends BaseRepository
Please login to merge, or discard this patch.
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -8,52 +8,52 @@
 block discarded – undo
8 8
 
9 9
 class UserRepository extends BaseRepository
10 10
 {
11
-    /**
12
-     * Init new object.
13
-     *
14
-     * @param   AclUser $model
15
-     * @return  void
16
-     */
17
-    public function __construct(AclUser $model)
18
-    {
19
-        parent::__construct($model);
20
-    }
11
+	/**
12
+	 * Init new object.
13
+	 *
14
+	 * @param   AclUser $model
15
+	 * @return  void
16
+	 */
17
+	public function __construct(AclUser $model)
18
+	{
19
+		parent::__construct($model);
20
+	}
21 21
 
22
-    /**
23
-     * Detach all roles from the given user.
24
-     *
25
-     * @param  mixed $user
26
-     * @return object
27
-     */
28
-    public function detachRoles($user)
29
-    {
30
-        $user = ! filter_var($user, FILTER_VALIDATE_INT) ? $user : $this->find($user);
31
-        $user->roles()->detach();
32
-    }
22
+	/**
23
+	 * Detach all roles from the given user.
24
+	 *
25
+	 * @param  mixed $user
26
+	 * @return object
27
+	 */
28
+	public function detachRoles($user)
29
+	{
30
+		$user = ! filter_var($user, FILTER_VALIDATE_INT) ? $user : $this->find($user);
31
+		$user->roles()->detach();
32
+	}
33 33
 
34
-    /**
35
-     * Attach role ids to the given user.
36
-     *
37
-     * @param  mixed $user
38
-     * @param  array $roleIds
39
-     * @return object
40
-     */
41
-    public function attachRoles($user, $roleIds)
42
-    {
43
-        $user = ! filter_var($user, FILTER_VALIDATE_INT) ? $user : $this->find($user);
44
-        $user->roles()->attach($roleIds);
45
-    }
34
+	/**
35
+	 * Attach role ids to the given user.
36
+	 *
37
+	 * @param  mixed $user
38
+	 * @param  array $roleIds
39
+	 * @return object
40
+	 */
41
+	public function attachRoles($user, $roleIds)
42
+	{
43
+		$user = ! filter_var($user, FILTER_VALIDATE_INT) ? $user : $this->find($user);
44
+		$user->roles()->attach($roleIds);
45
+	}
46 46
 
47
-    /**
48
-     * Count the given user the given roles.
49
-     *
50
-     * @param  mixed    $user
51
-     * @param  string[] $roles
52
-     * @return boolean
53
-     */
54
-    public function countRoles($user, $roles)
55
-    {
56
-        $user = ! filter_var($user, FILTER_VALIDATE_INT) ? $user : $this->find($user);
57
-        return $user->roles()->whereIn('name', $roles)->count();
58
-    }
47
+	/**
48
+	 * Count the given user the given roles.
49
+	 *
50
+	 * @param  mixed    $user
51
+	 * @param  string[] $roles
52
+	 * @return boolean
53
+	 */
54
+	public function countRoles($user, $roles)
55
+	{
56
+		$user = ! filter_var($user, FILTER_VALIDATE_INT) ? $user : $this->find($user);
57
+		return $user->roles()->whereIn('name', $roles)->count();
58
+	}
59 59
 }
Please login to merge, or discard this patch.