Merge branch 'giane' of https://github.com/BryamE/ProyectoLauck into giane
This commit is contained in:
@@ -2,16 +2,28 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Appointment extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
// Así podrás hacer cosas como $turno->fecha_programada->format('d/m/Y')
|
||||
protected $casts = [
|
||||
'fecha_programada' => 'datetime',
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'client_id',
|
||||
'scheduled_at',
|
||||
'bike_model',
|
||||
'problem_description',
|
||||
'status',
|
||||
'notes'
|
||||
];
|
||||
public function clients()
|
||||
|
||||
protected $casts = [
|
||||
'scheduled_at' => 'datetime', // Laravel lo convierte a objeto Carbon automáticamente
|
||||
];
|
||||
|
||||
// Relación: Un turno pertenece a un cliente
|
||||
public function client()
|
||||
{
|
||||
return $this->belongsTo(Client::class);
|
||||
}
|
||||
|
||||
@@ -2,15 +2,25 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Client extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $guarded = [];
|
||||
protected $fillable = ['name', 'phone', 'email', 'address'];
|
||||
|
||||
// Un usuario (cliente) realiza muchas compras (ventas)
|
||||
public function sales()
|
||||
{
|
||||
return $this->hasMany(Sale::class);
|
||||
}
|
||||
|
||||
|
||||
// Relación: Un cliente tiene muchos turnos
|
||||
public function appointments()
|
||||
{
|
||||
return $this->hasMany(Appointment::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,14 @@ class Product extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
public function hasLowStock(): bool
|
||||
{
|
||||
//cambiar
|
||||
return $this->stock_quantity <= $this->min_stock_alert;
|
||||
}
|
||||
|
||||
public function supplier()
|
||||
{
|
||||
return $this->belongsTo(Suppliers::class);
|
||||
@@ -27,7 +35,6 @@ class Product extends Model
|
||||
{
|
||||
return $this->belongsToMany(Sale::class, 'sale_details');
|
||||
}
|
||||
|
||||
}
|
||||
/**$user->sales: Te da la lista de todas las compras de ese usuario.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user