welcome modificado y traits

This commit is contained in:
cmoreno 2026-09-01 08:42:12 -03:00
parent 01cc1a2858
commit 28b82b9789
10 changed files with 133 additions and 120 deletions

BIN
BD/modelo.mwb Normal file

Binary file not shown.

View File

@ -29,6 +29,7 @@ class CategoriasController extends Controller
} }
public function show($id){ public function show($id){
$categoria = Categorias::findOrfail($id); $categoria = Categorias::findOrfail($id);
$categoria->formatear_texto();
return view('categorias.show', ["cat"=>$categoria]); return view('categorias.show', ["cat"=>$categoria]);
} }

View File

@ -0,0 +1,10 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class ProductoController extends Controller
{
//
}

View File

@ -5,11 +5,12 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use App\Traits\Herramientas;
class Categorias extends Model class Categorias extends Model
{ {
use HasFactory; use HasFactory;
use SoftDeletes; use SoftDeletes;
use Herramientas;
protected $table = 'categorias'; protected $table = 'categorias';
@ -20,4 +21,6 @@ class Categorias extends Model
'nombre', 'nombre',
'descripcion', 'descripcion',
]; ];
} }

View File

@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class CodigoBarras extends Model
{
use HasFactory;
use SoftDeletes;
protected $table = 'codigo_barras';
public $primaryKey = 'id_codigo_barras';
public $timestamps = true;
protected $fillable = [
'codigo',
];
}

21
app/Models/Etiquetas.php Normal file
View File

@ -0,0 +1,21 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Etiquetas extends Model
{
use HasFactory;
use SoftDeletes;
protected $table = 'etiquetas';
public $primaryKey = 'id_etiqueta';
public $timestamps = true;
protected $fillable = [
'nombre',
];
}

26
app/Models/Producto.php Normal file
View File

@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Producto extends Model
{
use HasFactory;
use SoftDeletes;
protected $table = 'productos';
public $primaryKey = 'id_producto';
public $timestamps = true;
protected $fillable = [
'nombre',
'descripcion',
'categoria_id',
'codigo_barras_id'
];
}

View File

@ -0,0 +1,14 @@
<?php
namespace App\Traits;
trait Herramientas {
public function formatear_texto() {
$this->nombre = ucwords(strtolower($this->nombre));
$this->update();
}
}

File diff suppressed because one or more lines are too long

View File

@ -30,5 +30,4 @@ Route::put('categorias/{categoria}', [CategoriasController::class, 'update'])->n
Route::resource('categorias', CategoriasController::class)->middleware('auth'); Route::resource('categorias', CategoriasController::class)->middleware('auth');
Route::put('categorias/restaurar/{categoria}', [CategoriasController::class, 'restaurar'])->name('categorias.restaurar')->middleware('auth'); Route::put('categorias/restaurar/{categoria}', [CategoriasController::class, 'restaurar'])->name('categorias.restaurar')->middleware('auth');
Auth::routes(); Auth::routes();
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home'); Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');