-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from IvanAquino/master
Sistema orm con eloquent
- Loading branch information
Showing
6 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
namespace FacturaScripts\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model as Eloquent; | ||
|
||
class Usuario extends Eloquent { | ||
protected $table = "fs_users"; | ||
protected $primaryKey = "nick"; | ||
public $incrementing = false; | ||
public $timestamps = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
namespace FacturaScripts\Controller; | ||
|
||
use FacturaScripts\Base\fs_controller; | ||
use FacturaScripts\Base\fs_plugin_manager; | ||
use FacturaScripts\Models\Usuario; | ||
|
||
class usuario_test extends fs_controller { | ||
|
||
public $usuario; | ||
|
||
public function __construct($folder = '', $className = __CLASS__) { | ||
parent::__construct($folder, $className); | ||
} | ||
|
||
public function run() { | ||
parent::run(); | ||
$this->usuario = Usuario::first(); | ||
|
||
if ( $this->request->getMethod() == "POST" ) | ||
{ | ||
$this->usuario->nick = $this->request->request->get('nick'); | ||
$this->usuario->email = $this->request->request->get('email'); | ||
|
||
if ( !$this->usuario->save() ) { | ||
$this->new_message($this->i18n->trans('user-unsaved')); | ||
} else { | ||
$this->new_message($this->i18n->trans('user-saved')); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{% extends "fs_template.html" %} | ||
|
||
{% block body %} | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-sm-12"> | ||
<div class="panel panel-info"> | ||
<div class="panel-heading"> | ||
Prueba de usuario | ||
</div> | ||
<div class="panel-body"> | ||
<form method="POST"> | ||
<div class="form-group"> | ||
<label for="nick" class="control-label">Nick</label> | ||
<input type="text" id="nick" name="nick" class="form-control" value="{{fsc.usuario.nick}}"> | ||
</div> | ||
<div class="form-group"> | ||
<label for="email" class="control-label">Email</label> | ||
<input type="text" id="email" name="email" class="form-control" value="{{fsc.usuario.email}}"> | ||
</div> | ||
<div class="text-center"> | ||
<button class="btn btn-primary" type="submit">Actualizar</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |