mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-10-22 00:03:25 -04:00
Initial commit
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\GeneralSetting\Repositories;
|
||||
|
||||
use Modules\GeneralSetting\Entities\UserNotificationSetting;
|
||||
|
||||
class UserNotificationSettingRepository
|
||||
{
|
||||
public function getByAuthUser($user_id=null)
|
||||
{
|
||||
$settings = UserNotificationSetting::where('user_id', $user_id)->with('notification_setting')->get();
|
||||
if($settings->count() == 0){
|
||||
(new UserNotificationSetting())->createForRegisterUser($user_id);
|
||||
$settings = UserNotificationSetting::where('user_id', $user_id)->with('notification_setting')->get();
|
||||
}
|
||||
return $settings;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function update($request, $id)
|
||||
{
|
||||
$notificationSetting = UserNotificationSetting::findOrFail($id);
|
||||
$notificationSetting->user_id = auth()->id();
|
||||
|
||||
if (is_array($request->type)) {
|
||||
$notificationtype = "";
|
||||
if ($request->type) {
|
||||
foreach ($request->type as $type) {
|
||||
$notificationtype .= $type . ",";
|
||||
}
|
||||
}
|
||||
$notificationSetting->type = $notificationtype;
|
||||
} else {
|
||||
|
||||
$notificationSetting->type = $request->type;
|
||||
}
|
||||
|
||||
|
||||
$notificationSetting->save();
|
||||
}
|
||||
|
||||
public function updateSettingForAPI($request){
|
||||
$notificationSetting = UserNotificationSetting::find($request->id);
|
||||
$notificationSetting->user_id = $request->user()->id;
|
||||
|
||||
if (is_array($request->type)) {
|
||||
$notificationtype = "";
|
||||
if ($request->type) {
|
||||
foreach ($request->type as $type) {
|
||||
$notificationtype .= $type . ",";
|
||||
}
|
||||
}
|
||||
$notificationSetting->type = $notificationtype;
|
||||
} else {
|
||||
|
||||
$notificationSetting->type = $request->type;
|
||||
}
|
||||
|
||||
$notificationSetting->save();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user