12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace App\Repositories;
- use App\Models\SmsBatch;
- use Prettus\Repository\Eloquent\BaseRepository;
- use Prettus\Repository\Criteria\RequestCriteria;
- /**
- * Class SmsBatchRepository.
- *
- * @package namespace App\Repositories;
- */
- class SmsBatchRepository extends BaseRepository
- {
- /**
- * Specify Model class name
- *
- * @return string
- */
- public function model()
- {
- return SmsBatch::class;
- }
-
- /**
- * Boot up the repository, pushing criteria
- */
- public function boot()
- {
- $this->pushCriteria(app(RequestCriteria::class));
- }
- /**
- * @param $batch_id
- * @param bool $status
- * @return mixed
- */
- public function updateBatch($batch_id, $status = true)
- {
- if ($batch_id == 0) {
- return;
- }
- $batch=$this->model->find($batch_id);
- $batch->send_num=$batch->send_num+($status?1:0);
- if ($batch->queues()->count() == $batch->target_num) {
- $batch->status=1;
- }
- $batch->save();
- }
-
- }
|