0
Controller
public function cadastro()
{
return View('/cadastro');
}
public function novo()
{
$user = \App\User::where('User',"=", Input::get("User"))->first();
$user->name = Input::get('name');
$user->host = Input::get('host');
$user->login = Input::get('login');
$user->password = hash('sha256', Input::get('password'));
$user->save($user);
}
Routes
Route::get('cadastro', 'Auth\RegisterController@cadastro');
Route::post('cadastro', 'Auth\RegisterController@novo');
View
<body>
<section method="POST" action="cadastro/novo">
<nav class="navbar navbar-default navbar-static-top">
<h1><b>CADASTRE SUA EMPRESA!</b></h1>
<hr>
</nav>
<div id="area">
<form id="formulario">
<fieldset style = "width: 200%; margin: 0px auto;">
<img src="/imagens/cliente.png" width="60px" height="60px" required/>
<input type="text" name="name" class="name" placeholder="Nome:" required><br>
<input type="text" name="host" class="host" placeholder="Host:" required><br>
<input type="text" name="email" class="email" placeholder="Email:" required><br>
<input type="password" name="password" class="senha" placeholder="Senha:" required>
<legend><input type="submit" value="Cadastrar" onclick="return change(this);"/></legend>
</fieldset>
</form>
</div>
</section>
<img class="canto" src="/imagens/unius.png"/>
<footer>
<p>Desenvolvido por: Vitória</p>
</footer>
Model User
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $fillable = [
'name', 'email','password','tipo'
];
protected $hidden = [
'password', 'remember_token', 'tipo'
];
public function clients ()
{
return $this->belongsToMany('App\client', 'client_user');
}
class clientUser extends Model
{
public $timestamps = false;
}
}
Table clients: This is my client table, which is where I’m struggling, because the form is not saving on it.
Table users: Where are my users.
Table clienteUser: Onde faz a relação das duas tabelas... Who is an admin user selects which clients developer users can see.
Register view!
Is there an error? this would be a new registration record?
– novic
No error, just not saved in the BD! And yes, it is a new record that should be saved in a table.
– Vitória
You are wearing Eloquent?
– novic
Yes, I’m!!!!!!
– Vitória
I made a reply helped you @Vitoria?
– novic
More or less @Virgilio.. Gives this error "Errorexception in Model.php line 485: Argument 1 passed to Illuminate Database Eloquent Model::save() must be of the type array, Object Given, called in C: Users Vit ria Desktop Project app Http Controllers Auth Registercontroller.php on line 189 and defined" so if I try to put a timestamps on the model, it gives error this error: "syntax error, Unexpected 'class' (T_CLASS), expecting Function (T_FUNCTION)"
– Vitória
Put your User things in question
– novic
I already put the code!
– Vitória
You put the class
clientUser
within theUser
, is wrong that too and one user can be multiple Clientesuser? Look at your programming that is wrong first and why of so many problems!– novic
It can be yes. Pq is a relationship table in Mysql.
– Vitória
Do the following Vitória put the layout of these two tables with the relationships in your question, I can generate the models and position you better, if you want of course...
– novic
@Virgilionovic I set the tables!
– Vitória
I put an answer if you saw Victoria?
– novic
@Virgilionovic N solved for me!
– Vitória