creacion del trait
This commit is contained in:
parent
894585138b
commit
d1c94a36db
|
|
@ -51,7 +51,7 @@ class LoginController extends Controller
|
|||
|
||||
if (Auth::attempt($credentials)) {
|
||||
$request->session()->regenerate();
|
||||
return redirect()->intended('/dashboard'); // ruta post-login
|
||||
return redirect()->intended('/personas'); // ruta post-login
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class PersonaController extends Controller
|
|||
}
|
||||
public function show($id){
|
||||
$persona = Persona::findOrfail($id);
|
||||
$persona-> formatear_texto();
|
||||
return view('personas.show', ["per"=>$persona]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,12 +5,15 @@ namespace App\Models;
|
|||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Traits\Herramientas;
|
||||
|
||||
class Persona extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use SoftDeletes;
|
||||
|
||||
use Herramientas;
|
||||
|
||||
protected $table = 'persona';
|
||||
|
||||
public $primaryKey = 'id_persona';
|
||||
|
|
|
|||
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
Loading…
Reference in New Issue
Block a user