Validaciones y Zonas de produccion
This commit is contained in:
23
backend/app/Exceptions/CantDeleteHasChildException.php
Normal file
23
backend/app/Exceptions/CantDeleteHasChildException.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class CantDeleteHasChildException extends Exception {
|
||||
|
||||
protected $parent;
|
||||
protected $child;
|
||||
|
||||
public function __construct($parent, $child) {
|
||||
$this->parent = $parent;
|
||||
$this->child = $child;
|
||||
}
|
||||
|
||||
public function render($request) {
|
||||
return response()->json([
|
||||
'error' => 'cant_delete',
|
||||
'message' => $this->parent . ' tiene ' . $this->child . ' asociados'
|
||||
], 400);
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,8 @@ class GenericException extends Exception {
|
||||
|
||||
public function render($request) {
|
||||
return response()->json([
|
||||
'error' => $this->error
|
||||
'error' => $this->error,
|
||||
'message' => $this->message
|
||||
], $status);
|
||||
], $this->status);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user