Comienzo de api de canales de venta

This commit is contained in:
2021-06-09 18:15:08 -04:00
parent 6583e8faaf
commit b3e4fe20cf
8 changed files with 300 additions and 9 deletions

View File

@@ -11,6 +11,15 @@ class CanalVenta extends Model {
protected $table = 'canales_venta';
public static function findOrNull($id) {
try {
return CanalVenta::find($id);
} catch (QueryException $ex) {
Log::warning('Se intento obtener un canal de venta con un id invalido', ['id' => $id]);
return null;
}
}
public function tipoCanal() {
return $this->belongsTo(TipoCanal::class);
}

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use App\Models\CanalVenta;
use App\Traits\UuidPrimaryKey;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -32,4 +33,8 @@ class Restaurante extends Model {
public function usuarios() {
return $this->belongsToMany(Usuario::class, 'usuarios_restaurantes', 'restaurante_id', 'usuario_id');
}
public function canalesVenta() {
return $this->hasMany(CanalVenta::class, 'restaurante_id');
}
}