Mejoras en la api

This commit is contained in:
2021-06-16 03:40:12 -04:00
parent 10f464eced
commit 64c05456af
10 changed files with 160 additions and 221 deletions

View File

@@ -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() {