forked from basemkhirat/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 13
/
DocumentNotFoundException.php
50 lines (40 loc) · 1.09 KB
/
DocumentNotFoundException.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
<?php
declare(strict_types=1);
namespace Matchory\Elasticsearch\Exceptions;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Arr;
use Matchory\Elasticsearch\Model;
use function count;
use function implode;
class DocumentNotFoundException extends ModelNotFoundException
{
/**
* The affected model IDs.
*
* @var string|array
*/
protected $ids = [];
/**
* Name of the affected Elasticsearch model.
*/
protected $model = '';
/**
* Set the affected Eloquent model and instance ids.
*
* @param class-string<Model> $model
* @param string|array $ids
*
* @return $this
* @psalm-suppress MoreSpecificImplementedParamType
*/
public function setModel($model, $ids = []): self
{
$this->model = $model;
$this->ids = Arr::wrap($ids);
$this->message = "No query results for model [{$model}]";
$this->message = count($this->ids) > 0
? $this->message . ' ' . implode(', ', $this->ids)
: $this->message . '.';
return $this;
}
}