24 lines
548 B
PHP
24 lines
548 B
PHP
<?php
|
|
|
|
namespace App\Exceptions;
|
|
|
|
use Exception;
|
|
|
|
class ModelNotFoundException extends Exception {
|
|
|
|
protected $modelName;
|
|
protected $id;
|
|
|
|
public function __construct($modelName, $id) {
|
|
$this->modelName= $modelName;
|
|
$this->id = is_array($id) ? implode(', ', $id) : $id;
|
|
}
|
|
|
|
public function render($request) {
|
|
return response()->json([
|
|
'error' => $this->modelName . '_not_found',
|
|
'message' => 'El ' . $this->modelName . ' con id ' . $this->id . ' no existe'
|
|
], 404);
|
|
}
|
|
}
|