sarga/packages/Webkul/Notification/src/Repositories/NotificationRepository.php

48 lines
1.8 KiB
PHP
Raw Normal View History

2021-12-30 13:30:13 +00:00
<?php
namespace Webkul\Notification\Repositories;
use Webkul\Core\Eloquent\Repository;
class NotificationRepository extends Repository
{
/**
* Specify Model class name
*
* @return mixed
*/
function model()
{
return 'Webkul\Notification\Contracts\Notification';
}
/**
* Return Filtered Notification resources
*
* @return objects
*/
public function getParamsData($params)
{
2022-03-15 05:07:58 +00:00
if (isset($params['id']) && isset($params['status'])) {
2022-03-15 05:39:33 +00:00
return $params['status'] != 'All' ? $this->model->where(function($qry) use ($params) {
2021-12-30 13:30:13 +00:00
$qry->whereHas('order',function ($q) use ($params) {
$q->where(['status' => $params['status']]);
});
2022-03-15 05:07:58 +00:00
})->where('order_id', $params['id'])->with('order')->paginate(10) : $this->model->where('order_id', $params['id'])->with('order')->paginate(10) ;
} else if (isset($params['status'])) {
2022-03-15 05:39:33 +00:00
return $params['status'] != 'All' ? $this->model->where(function($qry) use ($params) {
2021-12-30 13:30:13 +00:00
$qry->whereHas('order',function ($q) use ($params) {
$q->where(['status' => $params['status']]);
});
2021-12-31 12:57:34 +00:00
})->with('order')->paginate(10): $this->model->with('order')->latest()->paginate(10);
2022-03-15 05:39:33 +00:00
} else if(isset($params['read']) && isset($params['limit'])) {
return $this->model->where('read', $params['read'])->limit($params['limit'])->with('order')->latest()->paginate($params['limit']);
2022-03-15 05:07:58 +00:00
} else if(isset($params['limit'])) {
2022-03-15 05:39:33 +00:00
return $this->model;
2022-03-15 05:07:58 +00:00
} else if(isset($params['id'])) {
return $this->model->where('order_id', $params['id'])->with('order')->paginate(10);
2021-12-30 13:30:13 +00:00
}
return [];
}
}