Agrega Productos y sus recetas
This commit is contained in:
21
backend/app/Exceptions/AlreadyExistsException.php
Normal file
21
backend/app/Exceptions/AlreadyExistsException.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class AlreadyExistsException extends Exception {
|
||||
|
||||
protected $model;
|
||||
|
||||
public function __construct($model) {
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
public function render($request) {
|
||||
return response()->json([
|
||||
'error' => 'already_exists',
|
||||
'message' => 'Ya existe la ' . $this->model
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ class ModelNotFoundException extends Exception {
|
||||
|
||||
public function __construct($modelName, $id) {
|
||||
$this->modelName= $modelName;
|
||||
$this->id = $id;
|
||||
$this->id = is_array($id) ? implode(', ', $id) : $id;
|
||||
}
|
||||
|
||||
public function render($request) {
|
||||
|
||||
Reference in New Issue
Block a user