Mejoras en la api
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use App\Models\CanalVenta;
|
||||
use App\Traits\UuidPrimaryKey;
|
||||
use App\Exceptions\ModelNotFoundException;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\QueryException;
|
||||
@@ -21,13 +22,14 @@ class Restaurante extends Model {
|
||||
|
||||
protected $fillable = ['id', 'nombre'];
|
||||
|
||||
public static function findOrNull($id) {
|
||||
try {
|
||||
return Restaurante::find($id);
|
||||
} catch (QueryException $ex) {
|
||||
Log::warning('Se intento obtener un restaurante con un id invalido', ['id' => $id]);
|
||||
return null;
|
||||
public static function findOrFail($id) {
|
||||
$restaurante = Restaurante::find($id);
|
||||
|
||||
if(!$restaurante){
|
||||
throw new ModelNotFoundException("restaurant", $id);
|
||||
}
|
||||
|
||||
return $restaurante;
|
||||
}
|
||||
|
||||
public function usuarios() {
|
||||
|
||||
Reference in New Issue
Block a user