welcome modificado y traits
This commit is contained in:
parent
01cc1a2858
commit
28b82b9789
BIN
BD/modelo.mwb
Normal file
BIN
BD/modelo.mwb
Normal file
Binary file not shown.
|
|
@ -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]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
10
app/Http/Controllers/ProductoController.php
Normal file
10
app/Http/Controllers/ProductoController.php
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ProductoController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
@ -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',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
23
app/Models/CodigoBarras.php
Normal file
23
app/Models/CodigoBarras.php
Normal 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
21
app/Models/Etiquetas.php
Normal 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
26
app/Models/Producto.php
Normal 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'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
14
app/Traits/Herramientas.php
Normal file
14
app/Traits/Herramientas.php
Normal 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
|
|
@ -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');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user