Este commit está contenido en:
2025-10-08 20:26:57 -03:00
commit bbf08962cd
Se han modificado 64 ficheros con 14374 adiciones y 0 borrados

32
app/Models/Album.php Archivo normal
Ver fichero

@@ -0,0 +1,32 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Album extends Model
{
public function artista(): BelongsTo
{
return $this->belongsTo(Artista::class, 'ArtistId');
}
protected $fillable = ['AlbumId', 'Title'];
protected $table = 'albums'; //Si la tabla no es la esperada, definimos la variable $table con el nombre correspondiente.
protected $primaryKey = 'AlbumId'; // Si la PK es distinta a id, definimos la variable $primaryKey con el nombre correcto.
public $incrementing = true; //true o false según si es o no autoincrementable la columna. Si se hace por trigger, definir
// en false.
//protected $keyType = 'string'; Si el tipo no es entero, definimos la variable $keyType
public $timestamps = false;
}

40
app/Models/Artista.php Archivo normal
Ver fichero

@@ -0,0 +1,40 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Artista extends Model
{
public function albumes(): HasMany
{
return $this->hasMany(Album::class, 'ArtistId');
}
protected $fillable = ['ArtistId', 'Name'];
protected $table = 'artists'; //Si la tabla no es la esperada, definimos la variable $table con el nombre correspondiente.
protected $primaryKey = 'ArtistId'; // Si la PK es distinta a id, definimos la variable $primaryKey con el nombre correcto.
public $incrementing = true; //true o false según si es o no autoincrementable la columna. Si se hace por trigger, definir
// en false.
//protected $keyType = 'string'; Si el tipo no es entero, definimos la variable $keyType
public $timestamps = false;
/**
* Por defecto, Laravel espera que la tabla tenga las columnas created_at y updated_at
* Al crear o actualizar, Laravel se encarga de forma automática de actualizar esas columnas
* con la fecha actual.
*
* En caso que la tabla no las tenga, definir la variable $timestamps en false
*/
}

32
app/Models/Playlist.php Archivo normal
Ver fichero

@@ -0,0 +1,32 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Playlist extends Model
{
public function tracks(): BelongsToMany
{
return $this->belongsToMany(Track::class, 'playlist_track', 'PlaylistId', 'TrackId');
}
protected $fillable = ['PlaylistId', 'Name'];
protected $table = 'playlists'; //Si la tabla no es la esperada, definimos la variable $table con el nombre correspondiente.
protected $primaryKey = 'PlaylistId'; // Si la PK es distinta a id, definimos la variable $primaryKey con el nombre correcto.
public $incrementing = true; //true o false según si es o no autoincrementable la columna. Si se hace por trigger, definir
// en false.
//protected $keyType = 'string'; Si el tipo no es entero, definimos la variable $keyType
public $timestamps = false;
}

30
app/Models/Track.php Archivo normal
Ver fichero

@@ -0,0 +1,30 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class Track extends Model
{
public function playlists(): BelongsToMany
{
return $this->belongsToMany(Playlist::class, 'playlist_track', 'TrackId', 'PlaylistId');
}
protected $fillable = ['TrackId', 'Name', 'AlbumId', 'MediaTypeId', 'GenreId', 'Composer', 'Milliseconds', 'Bytes', 'UnitPrice'];
protected $table = 'tracks'; //Si la tabla no es la esperada, definimos la variable $table con el nombre correspondiente.
protected $primaryKey = 'TrackId'; // Si la PK es distinta a id, definimos la variable $primaryKey con el nombre correcto.
public $incrementing = true; //true o false según si es o no autoincrementable la columna. Si se hace por trigger, definir
// en false.
//protected $keyType = 'string'; Si el tipo no es entero, definimos la variable $keyType
public $timestamps = false;
}

48
app/Models/User.php Archivo normal
Ver fichero

@@ -0,0 +1,48 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
}