Skip to content

Commit 1b2e3f2

Browse files
Merge pull request #1267 from suraj-webkul/migration
Add expires_at column to personal access token.
2 parents cd0a2ed + 7162eaa commit 1b2e3f2

File tree

10 files changed

+607
-538
lines changed

10 files changed

+607
-538
lines changed

database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function up()
2020
$table->string('token', 64)->unique();
2121
$table->text('abilities')->nullable();
2222
$table->timestamp('last_used_at')->nullable();
23+
$table->timestamp('expires_at')->nullable();
2324
$table->timestamps();
2425
});
2526
}

packages/Webkul/Admin/src/Http/Controllers/User/AccountController.php

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Support\Facades\Hash;
66
use Illuminate\Support\Facades\Event;
7+
use Illuminate\Support\Facades\Storage;
78
use Webkul\Admin\Http\Controllers\Controller;
89

910
class AccountController extends Controller
@@ -36,7 +37,8 @@ public function update()
3637
'email' => 'email|unique:users,email,' . $user->id,
3738
'password' => 'nullable|min:6|confirmed',
3839
'current_password' => 'nullable|required|min:6',
39-
'image' => 'mimes:jpeg,jpg,png,gif'
40+
'image' => 'mimes:jpeg,jpg,png,gif',
41+
'remove_image' => 'sometimes|boolean',
4042
]);
4143

4244
$data = request()->input();
@@ -61,13 +63,7 @@ public function update()
6163
$data['password'] = bcrypt($data['password']);
6264
}
6365

64-
if (request()->hasFile('image')) {
65-
$data['image'] = request()->file('image')->store('users/' . $user->id);
66-
}
67-
68-
if (isset($data['remove_image']) && $data['remove_image'] !== '') {
69-
$data['image'] = null;
70-
}
66+
$this->handleProfileImageUpload($data, $user);
7167

7268
$user->update($data);
7369

@@ -79,4 +75,38 @@ public function update()
7975

8076
return redirect()->route('admin.dashboard.index');
8177
}
78+
79+
/**
80+
* Handle profile image upload.
81+
*
82+
* @param array $data
83+
* @param Object $user
84+
* @return void
85+
*/
86+
public function handleProfileImageUpload(&$data, $user)
87+
{
88+
$oldImage = $user->image;
89+
90+
if (! isset($data['image'])) {
91+
$data['image'] = $user->image;
92+
}
93+
94+
if (request()->hasFile('image')) {
95+
$data['image'] = request()->file('image')->store('users/' . $user->id);
96+
}
97+
98+
if (
99+
isset($data['remove_image'])
100+
&& $data['remove_image']
101+
) {
102+
$data['image'] = null;
103+
}
104+
105+
if (
106+
$oldImage
107+
&& ($data['image'] !== $oldImage)
108+
) {
109+
Storage::delete($oldImage);
110+
}
111+
}
82112
}

packages/Webkul/Admin/src/Http/Requests/LeadForm.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,26 @@ public function rules()
129129
}
130130
}
131131

132-
return $this->rules;
132+
return [
133+
...$this->rules,
134+
'products' => 'array',
135+
'products.*.product_id' => 'sometimes|required|exists:products,id',
136+
'products.*.name' => 'required_with:products.*.product_id',
137+
'products.*.price' => 'required_with:products.*.product_id',
138+
'products.*.quantity' => 'required_with:products.*.product_id',
139+
];
140+
}
141+
142+
/**
143+
* Get the validation messages that apply to the request.
144+
*/
145+
public function messages(): array
146+
{
147+
return [
148+
'products.*.product_id.exists' => trans('admin::app.leads.selected-product-not-exist'),
149+
'products.*.name.required_with' => trans('admin::app.leads.product-name-required'),
150+
'products.*.price.required_with' => trans('admin::app.leads.product-price-required'),
151+
'products.*.quantity.required_with' => trans('admin::app.leads.product-quantity-required'),
152+
];
133153
}
134154
}

packages/Webkul/Admin/src/Resources/lang/ar/app.php

Lines changed: 109 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -118,111 +118,115 @@
118118
],
119119

120120
'leads' => [
121-
'title' => 'يؤدي',
122-
'lead' => 'قيادة',
123-
'create-title' => 'خلق الرصاص',
124-
'edit-title' => 'تحرير الرصاص',
125-
'save-btn-title' => 'حفظ كقائد',
126-
'save' => 'يحفظ',
127-
'upload' => 'تحميل',
128-
'back' => 'خلف',
129-
'cancel' => 'يلغي',
130-
'no-lead' => 'لا يؤدي',
131-
'lead-source-name' => 'مصدر الدليل',
132-
'details' => 'تفاصيل',
133-
'rotten-info' => 'الرصاص قد تعفن ل :days day(s)',
134-
'stage' => 'المسرح',
135-
'new' => 'جديد',
136-
'won-lost' => 'فاز / خسر',
137-
'won' => 'وون',
138-
'lost' => 'ضائع',
139-
'change-stage' => 'مرحلة التغيير',
140-
'lost-reason' => 'سبب ضائع',
141-
'won-value' => 'قيمة الفوز',
142-
'created-date:' => 'تاريخ الإنشاء:',
143-
'closed-date:' => 'تاريخ مغلق:',
144-
'closed-date' => 'تاريخ مغلق',
145-
'expected-close-date:' => 'تاريخ الإغلاق المتوقع:',
146-
'contact-person' => 'الشخص الذي يمكن الاتصال به',
147-
'add-tag' => 'إضافة علامة',
148-
'search-tag' => 'بحث الوسم',
149-
'name' => 'اسم',
150-
'color' => 'اللون',
151-
'email' => 'بريد الالكتروني',
152-
'contact-numbers' => 'ارقام التواصل',
153-
'organization' => 'منظمة',
154-
'address' => 'عنوان',
155-
'products' => 'منتجات',
156-
'item' => 'غرض',
157-
'price' => 'سعر',
158-
'quantity' => 'كمية',
159-
'amount' => 'كمية',
160-
'create-success' => 'تم إنشاء العميل المحتمل بنجاح.',
161-
'update-success' => 'تم تحديث العميل المحتمل بنجاح.',
162-
'delete-success' => 'تم حذف الرصاص بنجاح.',
163-
'delete-failed' => 'لا يمكن حذف الرصاص.',
164-
'note' => 'ملحوظة',
165-
'activity' => 'نشاط',
166-
'title-control' => 'عنوان',
167-
'call' => 'مكالمة',
168-
'meeting' => 'لقاء',
169-
'lunch' => 'غداء',
170-
'file' => 'ملف',
171-
'quote' => 'اقتبس',
172-
'create-quote' => 'إنشاء اقتباس',
173-
'type' => 'نوع',
174-
'description' => 'وصف',
175-
'schedule' => 'جدول',
176-
'from' => 'من عند',
177-
'to' => 'إلى',
178-
'location' => 'موقع',
179-
'participants' => 'مشاركون',
180-
'participant-info' => 'ابدأ في كتابة الاسم',
181-
'users' => 'المستخدمون',
182-
'persons' => 'الأشخاص',
183-
'cc' => 'نسخة',
184-
'bcc' => 'نسخة مخفية الوجهة',
185-
'email-placeholder' => 'اضغط على يدخل لإضافة رسائل بريد إلكتروني',
186-
'file' => 'ملف',
187-
'subject' => 'موضوعات',
188-
'reply' => 'رد',
189-
'send' => 'يرسل',
190-
'all' => 'الجميع',
191-
'notes' => 'ملحوظات',
192-
'select-type' => 'اختر صنف',
193-
'calls' => 'المكالمات',
194-
'meetings' => 'الاجتماعات',
195-
'lunches' => 'وجبات الغداء',
196-
'emails' => 'رسائل البريد الإلكتروني',
197-
'files' => 'الملفات',
198-
'sales-owner' => 'مالك المبيعات',
199-
'person' => 'شخص',
200-
'expired-at' => 'منتهي الصلاحية في',
201-
'sub-total' => 'المجموع الفرعي',
202-
'discount' => 'خصم',
203-
'tax' => 'ضريبة',
204-
'adjustment' => 'تعديل',
205-
'grand-total' => 'المبلغ الإجمالي',
206-
'actions' => 'أجراءات',
207-
'planned' => 'مخطط',
208-
'done' => 'منتهي',
209-
'edit' => 'يحرر',
210-
'view' => 'منظر',
211-
'unlink' => 'إلغاء الارتباط',
212-
'mark-as-done' => 'اعتبره منته',
213-
'remove' => 'يزيل',
214-
'export-to-pdf' => 'تصدير إلى PDF',
215-
'empty-planned-activities' => 'ليس لديك أنشطة مخطط لها.',
216-
'empty-done-activities' => 'لم تقم بأي أنشطة.',
217-
'note-added' => 'تمت إضافة الملاحظة',
218-
'call-scheduled' => 'تمت جدولة المكالمة في :from - :to',
219-
'meeting-scheduled' => 'الاجتماع المقرر في :from - :to',
220-
'lunch-scheduled' => 'الغداء المقرر في :from - :to',
221-
'file-added' => 'تمت إضافة الملف',
222-
'quote-destroy-success' => 'تمت إزالة الاقتباس بنجاح.',
223-
'tag-create-success' => 'تمت إضافة العلامة بنجاح.',
224-
'tag-destroy-success' => 'تمت إزالة العلامة بنجاح.',
225-
'edit' => 'تعديل',
121+
'title' => 'يؤدي',
122+
'lead' => 'قيادة',
123+
'create-title' => 'خلق الرصاص',
124+
'edit-title' => 'تحرير الرصاص',
125+
'save-btn-title' => 'حفظ كقائد',
126+
'save' => 'يحفظ',
127+
'upload' => 'تحميل',
128+
'back' => 'خلف',
129+
'cancel' => 'يلغي',
130+
'no-lead' => 'لا يؤدي',
131+
'lead-source-name' => 'مصدر الدليل',
132+
'details' => 'تفاصيل',
133+
'rotten-info' => 'الرصاص قد تعفن ل :days day(s)',
134+
'stage' => 'المسرح',
135+
'new' => 'جديد',
136+
'won-lost' => 'فاز / خسر',
137+
'won' => 'وون',
138+
'lost' => 'ضائع',
139+
'change-stage' => 'مرحلة التغيير',
140+
'lost-reason' => 'سبب ضائع',
141+
'won-value' => 'قيمة الفوز',
142+
'created-date:' => 'تاريخ الإنشاء:',
143+
'closed-date:' => 'تاريخ مغلق:',
144+
'closed-date' => 'تاريخ مغلق',
145+
'expected-close-date:' => 'تاريخ الإغلاق المتوقع:',
146+
'contact-person' => 'الشخص الذي يمكن الاتصال به',
147+
'add-tag' => 'إضافة علامة',
148+
'search-tag' => 'بحث الوسم',
149+
'name' => 'اسم',
150+
'color' => 'اللون',
151+
'email' => 'بريد الالكتروني',
152+
'contact-numbers' => 'ارقام التواصل',
153+
'organization' => 'منظمة',
154+
'address' => 'عنوان',
155+
'products' => 'منتجات',
156+
'item' => 'غرض',
157+
'price' => 'سعر',
158+
'quantity' => 'كمية',
159+
'amount' => 'كمية',
160+
'create-success' => 'تم إنشاء العميل المحتمل بنجاح.',
161+
'update-success' => 'تم تحديث العميل المحتمل بنجاح.',
162+
'delete-success' => 'تم حذف الرصاص بنجاح.',
163+
'delete-failed' => 'لا يمكن حذف الرصاص.',
164+
'product-quantity-required' => 'الكمية المطلوبة للمنتج مطلوبة عندما يكون معرف المنتج موجودًا.',
165+
'product-price-required' => 'سعر المنتج مطلوب عندما يكون معرف المنتج موجودًا.',
166+
'product-name-required' => 'اسم المنتج مطلوب عندما يكون معرف المنتج موجودًا.',
167+
'selected-product-not-exist' => 'معرف المنتج المحدد غير موجود.',
168+
'note' => 'ملحوظة',
169+
'activity' => 'نشاط',
170+
'title-control' => 'عنوان',
171+
'call' => 'مكالمة',
172+
'meeting' => 'لقاء',
173+
'lunch' => 'غداء',
174+
'file' => 'ملف',
175+
'quote' => 'اقتبس',
176+
'create-quote' => 'إنشاء اقتباس',
177+
'type' => 'نوع',
178+
'description' => 'وصف',
179+
'schedule' => 'جدول',
180+
'from' => 'من عند',
181+
'to' => 'إلى',
182+
'location' => 'موقع',
183+
'participants' => 'مشاركون',
184+
'participant-info' => 'ابدأ في كتابة الاسم',
185+
'users' => 'المستخدمون',
186+
'persons' => 'الأشخاص',
187+
'cc' => 'نسخة',
188+
'bcc' => 'نسخة مخفية الوجهة',
189+
'email-placeholder' => 'اضغط على يدخل لإضافة رسائل بريد إلكتروني',
190+
'file' => 'ملف',
191+
'subject' => 'موضوعات',
192+
'reply' => 'رد',
193+
'send' => 'يرسل',
194+
'all' => 'الجميع',
195+
'notes' => 'ملحوظات',
196+
'select-type' => 'اختر صنف',
197+
'calls' => 'المكالمات',
198+
'meetings' => 'الاجتماعات',
199+
'lunches' => 'وجبات الغداء',
200+
'emails' => 'رسائل البريد الإلكتروني',
201+
'files' => 'الملفات',
202+
'sales-owner' => 'مالك المبيعات',
203+
'person' => 'شخص',
204+
'expired-at' => 'منتهي الصلاحية في',
205+
'sub-total' => 'المجموع الفرعي',
206+
'discount' => 'خصم',
207+
'tax' => 'ضريبة',
208+
'adjustment' => 'تعديل',
209+
'grand-total' => 'المبلغ الإجمالي',
210+
'actions' => 'أجراءات',
211+
'planned' => 'مخطط',
212+
'done' => 'منتهي',
213+
'edit' => 'يحرر',
214+
'view' => 'منظر',
215+
'unlink' => 'إلغاء الارتباط',
216+
'mark-as-done' => 'اعتبره منته',
217+
'remove' => 'يزيل',
218+
'export-to-pdf' => 'تصدير إلى PDF',
219+
'empty-planned-activities' => 'ليس لديك أنشطة مخطط لها.',
220+
'empty-done-activities' => 'لم تقم بأي أنشطة.',
221+
'note-added' => 'تمت إضافة الملاحظة',
222+
'call-scheduled' => 'تمت جدولة المكالمة في :from - :to',
223+
'meeting-scheduled' => 'الاجتماع المقرر في :from - :to',
224+
'lunch-scheduled' => 'الغداء المقرر في :from - :to',
225+
'file-added' => 'تمت إضافة الملف',
226+
'quote-destroy-success' => 'تمت إزالة الاقتباس بنجاح.',
227+
'tag-create-success' => 'تمت إضافة العلامة بنجاح.',
228+
'tag-destroy-success' => 'تمت إزالة العلامة بنجاح.',
229+
'edit' => 'تعديل',
226230
],
227231

228232
'quotes' => [

0 commit comments

Comments
 (0)