Skip to content

Commit 9296582

Browse files
committed
First commit
0 parents  commit 9296582

File tree

7 files changed

+160
-0
lines changed

7 files changed

+160
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_Store
2+
composer.lock
3+
vendor/

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[MIT LICENSE]
2+
3+
Copyright (c) 2019 repat, https://repat.de
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
Software), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, andor sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# laravel-job-models
2+
[![Latest Version on Packagist](https://img.shields.io/packagist/v/repat/laravel-job-models.svg?style=flat-square)](https://packagist.org/packages/repat/laravel-job-models)
3+
[![Total Downloads](https://img.shields.io/packagist/dt/repat/laravel-job-models.svg?style=flat-square)](https://packagist.org/packages/repat/laravel-job-models)
4+
5+
**laravel-job-models** contains 2 Eloquent models for the tables `jobs` and `job_fails` as created by the 2 artisan commands `queue:table` and `queue:failed-table`.
6+
7+
## Installation
8+
`$ composer require repat/laravel-job-models`
9+
10+
## Documentation
11+
12+
#### Casting
13+
There is a casting to `\Carbon\Carbon` objects for: `reserved_at`, `available_at`, `created_at` and `failed_at` and a casting to array for `payload`.
14+
15+
#### Attributes/ Mutators
16+
There are getters for all the keys of the payload, including the `data` array. For more information, see the [Laravel Documentation on Eloquent Mutators](https://laravel.com/docs/5.8/eloquent-mutators).
17+
18+
```php
19+
$job = \Repat\LaravelJobs\Job::first();
20+
21+
$job->display_name;
22+
$job->max_tries;
23+
$job->delay;
24+
$job->timeout;
25+
$job->timeout_at; // cast to Carbon if not null
26+
$job->command_name; // ->payload['data']['commandName']
27+
$job->command; // unserialized
28+
```
29+
30+
## License
31+
* MIT, see [LICENSE](https://github.com/repat/laravel-job-models/blob/master/LICENSE)
32+
33+
## Version
34+
* Version 0.1
35+
36+
## Contact
37+
#### repat
38+
* Homepage: https://repat.de
39+
40+
* Twitter: [@repat123](https://twitter.com/repat123 "repat123 on twitter")
41+
42+
[![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=repat&url=https://github.com/repat/laravel-job-models&title=laravel-job-models&language=&tags=github&category=software)

composer.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "repat/laravel-job-models",
3+
"description": "Eloquent Models for the tables job and job_fails as created by artisan queue:table and queue:failed-table",
4+
"keywords": ["laravel", "eloquent", "job", "jobs", "model", "job_fails", "artisan", "queue:table"],
5+
"homepage": "https://repat.de",
6+
"license": "MIT",
7+
"version" : "0.1",
8+
"authors": [
9+
{"name": "repat", "email": "[email protected]"}
10+
],
11+
"require": {
12+
"php": ">=5.6",
13+
"laravel/framework": "^5.0"
14+
},
15+
"autoload": {
16+
"psr-4": {
17+
"Repat\\LaravelJobs\\": "src/Repat/LaravelJobs"
18+
}
19+
}
20+
}

src/Repat/LaravelJobs/Attributes.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace Repat\LaravelJobs;
4+
5+
trait Attributes
6+
{
7+
public function getDisplayNameAttribute()
8+
{
9+
return $this->payload['displayName'];
10+
}
11+
12+
public function getMaxTriesAttribute()
13+
{
14+
return $this->payload['maxTries'];
15+
}
16+
17+
public function getDelayAttribute()
18+
{
19+
return $this->payload['delay'];
20+
}
21+
22+
public function getTimeoutAttribute()
23+
{
24+
return $this->payload['timeout'];
25+
}
26+
27+
public function getTimeoutAtAttribute()
28+
{
29+
return !is_null($this->payload['timeout_at']) ? new \Carbon\Carbon($this->payload['timeout_at']) : null;
30+
}
31+
32+
public function getCommandNameAttribute()
33+
{
34+
return $this->payload['data']['commandName'];
35+
}
36+
37+
public function getCommandAttribute()
38+
{
39+
return unserialize($this->payload['data']['command']);
40+
}
41+
}

src/Repat/LaravelJobs/Job.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Repat\LaravelJobs;
4+
5+
class Job extends \Illuminate\Database\Eloquent\Model
6+
{
7+
use Attributes;
8+
9+
public $timestamps = false;
10+
11+
protected $casts = [
12+
'payload' => 'array',
13+
'reserved_at' => 'datetime',
14+
'available_at' => 'datetime',
15+
'created_at' => 'datetime',
16+
];
17+
}

src/Repat/LaravelJobs/JobFail.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Repat\LaravelJobs;
4+
5+
class JobFail extends \Illuminate\Database\Eloquent\Model
6+
{
7+
use Attributes;
8+
9+
public $timestamps = false;
10+
11+
protected $casts = [
12+
'payload' => 'array',
13+
'failed_at' => 'datetime',
14+
];
15+
}

0 commit comments

Comments
 (0)