forked from mongodb/laravel-mongodb
-
Notifications
You must be signed in to change notification settings - Fork 37
/
MongoFailedJobProvider.php
66 lines (56 loc) · 1.44 KB
/
MongoFailedJobProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php namespace Moloquent\Queue\Failed;
use Carbon\Carbon;
use Illuminate\Queue\Failed\DatabaseFailedJobProvider;
class MongoFailedJobProvider extends DatabaseFailedJobProvider
{
/**
* Log a failed job into storage.
*
* @param string $connection
* @param string $queue
* @param string $payload
* @param \Exception $exception
* @return int|null
*/
public function log($connection, $queue, $payload, $exception)
{
$failed_at = Carbon::now()->getTimestamp();
$this->getTable()->insert(compact('connection', 'queue', 'payload', 'failed_at','exception'));
}
/**
* Get a list of all of the failed jobs.
*
* @return array
*/
public function all()
{
$all = $this->getTable()->orderBy('_id', 'desc')->get();
$all = array_map(function ($job) {
$job['id'] = (string) $job['_id'];
return $job;
}, $all);
return $all;
}
/**
* Get a single failed job.
*
* @param mixed $id
* @return array
*/
public function find($id)
{
$job = $this->getTable()->find($id);
$job['id'] = (string) $job['_id'];
return $job;
}
/**
* Delete a single failed job from storage.
*
* @param mixed $id
* @return bool
*/
public function forget($id)
{
return $this->getTable()->where('_id', $id)->delete() > 0;
}
}