Skip to content

Commit

Permalink
Merge pull request #45 from Crudzaso/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
DiegoAndresRamirez authored Nov 8, 2024
2 parents 69ef388 + 80c07e1 commit cf0fb93
Show file tree
Hide file tree
Showing 92 changed files with 6,362 additions and 1,606 deletions.
19 changes: 13 additions & 6 deletions Modules/Draws/app/Models/Draws.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
// use Modules\Draws\Database\Factories\DrawsFactory;
use Modules\Lotery\Models\Lotery;

class Draws extends Model
{
Expand All @@ -13,10 +13,17 @@ class Draws extends Model
/**
* The attributes that are mass assignable.
*/
protected $fillable = [];
protected $fillable = [
'lottery_id',
'draw_date',
'winning_numbers',
];

// protected static function newFactory(): DrawsFactory
// {
// // return DrawsFactory::new();
// }
/**
* Get the lottery associated with the draw.
*/
public function lottery()
{
return $this->belongsTo(Lotery::class);
}
}
25 changes: 18 additions & 7 deletions Modules/Lotery/app/Models/Lotery.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,30 @@

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
// use Modules\Lotery\Database\Factories\LoteryFactory;

class Lotery extends Model
{
use HasFactory;

/**
* The attributes that are mass assignable.
* El nombre de la tabla asociada al modelo.
*
* @var string
*/
protected $fillable = [];
protected $table = 'lotteries'; // Especificamos la tabla correctamente

// protected static function newFactory(): LoteryFactory
// {
// // return LoteryFactory::new();
// }
/**
* Los atributos que se pueden asignar masivamente.
*
* @var array
*/
protected $fillable = ['name', 'description', 'image_url']; // Agregar 'description' e 'image_url' para la asignación masiva

/**
* Las relaciones de los sorteos con esta lotería (relación inversa).
*/
public function draws()
{
return $this->hasMany(\Modules\Draws\Models\Draws::class, 'lottery_id');
}
}
18 changes: 14 additions & 4 deletions Modules/Multimedia/app/Models/Multimedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,29 @@

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
// use Modules\Multimedia\Database\Factories\MultimediaFactory;

class Multimedia extends Model
{
use HasFactory;

/**
* The attributes that are mass assignable.
* Los atributos que son asignables masivamente.
*
* @var array
*/
protected $fillable = [];
protected $fillable = [
'file_name',
'file_path',
'file_type',
'mime_type',
'size',
'model_id',
'model_type',
];

// Si tienes un Factory, puedes activarlo aquí
// protected static function newFactory(): MultimediaFactory
// {
// // return MultimediaFactory::new();
// return MultimediaFactory::new();
// }
}
20 changes: 11 additions & 9 deletions Modules/Payment/app/Models/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
// use Modules\Payment\Database\Factories\PaymentFactory;
use Modules\Raffle\Models\Raffle;

class Payment extends Model
{
use HasFactory;

/**
* The attributes that are mass assignable.
*/
protected $fillable = [];
protected $fillable = ['user_id', 'raffle_id', 'amount', 'payment_method', 'payment_date'];

// protected static function newFactory(): PaymentFactory
// {
// // return PaymentFactory::new();
// }
public function user()
{
return $this->belongsTo(\App\Models\User::class);
}

public function raffle()
{
return $this->belongsTo(Raffle::class);
}
}
31 changes: 22 additions & 9 deletions Modules/Raffle/app/Models/Raffle.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,32 @@

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
// use Modules\Raffle\Database\Factories\RaffleFactory;
use App\Models\User; // Importar User para la relación
use Modules\Lotery\Models\Lotery;
use Modules\Lottery\Models\Lottery; // Importar Lottery para la relación

class Raffle extends Model
{
use HasFactory;

/**
* The attributes that are mass assignable.
*/
protected $fillable = [];
protected $fillable = [
'organizer_id',
'lottery_id',
'ticket_price',
'total_tickets',
'tickets_sold',
'description',
'start_date',
'end_date',
];

// protected static function newFactory(): RaffleFactory
// {
// // return RaffleFactory::new();
// }
public function organizer()
{
return $this->belongsTo(User::class, 'organizer_id');
}

public function lottery()
{
return $this->belongsTo(Lotery::class, 'lottery_id');
}
}
21 changes: 14 additions & 7 deletions Modules/Reward/app/Models/Reward.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,26 @@

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
// use Modules\Reward\Database\Factories\RewardFactory;

class Reward extends Model
{
use HasFactory;

/**
* The attributes that are mass assignable.
* Los atributos que son asignables de forma masiva.
*/
protected $fillable = [];
protected $fillable = [
'user_id', // ID del usuario al que se le asignan los puntos
'points', // Puntos acumulados
'redeemed_points', // Puntos canjeados
];

// protected static function newFactory(): RewardFactory
// {
// // return RewardFactory::new();
// }
/**
* Relación con el modelo User.
* Un usuario puede tener una recompensa.
*/
public function user()
{
return $this->belongsTo(\App\Models\User::class); // Relación con el modelo User
}
}
33 changes: 27 additions & 6 deletions Modules/Ticket/app/Models/Ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
// use Modules\Ticket\Database\Factories\TicketFactory;
use Modules\Raffle\Models\Raffle; // Importar el modelo de Raffle
use App\Models\User; // Importar el modelo de User

class Ticket extends Model
{
Expand All @@ -13,10 +14,30 @@ class Ticket extends Model
/**
* The attributes that are mass assignable.
*/
protected $fillable = [];
protected $fillable = [
'raffle_id',
'user_id',
'ticket_number',
'purchase_date',
'end_date',
'verification_code',
];

// protected static function newFactory(): TicketFactory
// {
// // return TicketFactory::new();
// }
/**
* Relación de un ticket con una rifa (Raffle).
* Un ticket pertenece a una rifa.
*/
public function raffle()
{
return $this->belongsTo(Raffle::class, 'raffle_id');
}

/**
* Relación de un ticket con un usuario (User).
* Un ticket pertenece a un usuario.
*/
public function user()
{
return $this->belongsTo(User::class, 'user_id');
}
}
109 changes: 109 additions & 0 deletions app/Filament/Resources/DrawsResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php

namespace App\Filament\Resources;

use App\Filament\Resources\DrawsResource\Pages;
use App\Filament\Resources\DrawsResource\RelationManagers;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Modules\Draws\Models\Draws as ModelsDraws;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\TextArea;
use Filament\Forms\Components\Select;
use Filament\Tables\Columns\TextColumn;
use Modules\Lotery\Models\Lotery;

class DrawsResource extends Resource
{
protected static ?string $model = ModelsDraws::class;

protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

protected static ?string $navigationGroup = 'Models';

protected static ?int $navigationSort = 1;

// Configuración del formulario
public static function form(Form $form): Form
{
return $form
->schema([
Select::make('lottery_id')
->label('Lottery')
->options(function () {
return Lotery::all()->pluck('name', 'id');
})
->required()
->placeholder('Select Lottery'),

DateTimePicker::make('draw_date')
->label('Draw Date')
->required()
->displayFormat('Y-m-d H:i:s')
->withoutSeconds(),

TextArea::make('winning_numbers')
->label('Winning Numbers')
->nullable()
->maxLength(255),
]);
}

// Configuración de la tabla
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('lottery.name') // Mostrar el nombre de la lotería asociada
->label('Lottery')
->sortable()
->searchable(),

TextColumn::make('draw_date')
->label('Draw Date')
->sortable()
->searchable()
->dateTime(),

TextColumn::make('winning_numbers')
->label('Winning Numbers')
->sortable()
->searchable(),

TextColumn::make('created_at')
->label('Created At')
->sortable()
->dateTime(),
])
->filters([
// Puedes agregar filtros si es necesario
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
]);
}

public static function getRelations(): array
{
return [
// Si deseas agregar más relaciones, agrégalas aquí
];
}

public static function getPages(): array
{
return [
'index' => Pages\ListDraws::route('/'),
'create' => Pages\CreateDraws::route('/create'),
'edit' => Pages\EditDraws::route('/{record}/edit'),
];
}
}
12 changes: 12 additions & 0 deletions app/Filament/Resources/DrawsResource/Pages/CreateDraws.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Filament\Resources\DrawsResource\Pages;

use App\Filament\Resources\DrawsResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;

class CreateDraws extends CreateRecord
{
protected static string $resource = DrawsResource::class;
}
19 changes: 19 additions & 0 deletions app/Filament/Resources/DrawsResource/Pages/EditDraws.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Filament\Resources\DrawsResource\Pages;

use App\Filament\Resources\DrawsResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;

class EditDraws extends EditRecord
{
protected static string $resource = DrawsResource::class;

protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
}
Loading

0 comments on commit cf0fb93

Please sign in to comment.