os comento, tengo una tarea que no termino de entender muy bien, la verdad:
Tengo que crear un controlador con Laravel llamado SettingsController, la cosa es que con este controlador puedo actualizar la información pública o la información privada, por lo que tendría que tener métodos update en el controlador que tengo que crear.
Me han pasado un ejemplo de controlador y una estructura de la tabla usuarios.
La clase RegisterController.php que tengo como ejemplo
use IssueTokenTrait;
private $client;
public function __construct()
{
$this->client = Client::where('name', 'UNBLND Password Grant Client')->first();
}
public function exists(Request $request)
{
$request->validate([
'email' => 'required|email|unique:users,email',
]);
return response()->json(['exists' => false]);
}
public function register(Request $request) {
$this->validate($request, [
'name' => 'required|string|max:255',
'email' => 'required|email|unique:users,email',
'password' => 'required|min:6|confirmed',
]);
$u = User::create([
'name' => request('name'),
'email' => request('email'),
'avatar' => str_random(10),
'password' => Hash::make(request('password')),
]);
$position = \Location::get(request('ip'));
if ( is_numeric($position->latitude) && is_numeric($position->longitude) ) {
\Log::info('Register user_id ' . $u->id . ' location: ' . $position->latitude . ',' . $position->longitude);
Location::create([
'user_id' => $u->id,
'longitude' => $position->longitude,
'latitude' => $position->latitude
]);
}
return $this->issueToken($request, 'password');
}
}
y aquí la estructura de la tabla de usuarios
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('first_name')->nullable();
$table->string('last_name')->nullable();
$table->string('email')->unique()->nullable();
$table->date('birth_date')->nullable();
$table->integer('age_group_id')->unsigned()->nullable();
$table->string('avatar');
$table->string('avatar_hex', 7)->nullable();
$table->timestamp('email_verified_at')->nullable();
$table->boolean('is_blocked')->default(false);
$table->string('password')->nullable();
$table->string('facebook_id', 50)->nullable();
$table->text('facebook_token')->nullable();
$table->string('twitter_id', 50)->nullable();
$table->text('twitter_token')->nullable();
$table->string('instagram_id', 50)->nullable();
$table->text('instagram_token')->nullable();
$table->string('public_info', 600)->nullable();
$table->string('private_info', 600)->nullable();
$table->boolean('is_privacy_important')->nullable();
$table->boolean('is_ambassador')->default(false);
$table->smallInteger('email_frequency')->unsigned()->default(0);
$table->boolean('email_when_new_group')->default(true);
$table->boolean('email_when_invited')->default(true);
$table->boolean('email_when_welcome')->default(true);
$table->boolean('email_when_unread')->default(true);
$table->boolean('email_when_request')->default(true);
$table->boolean('email_when_accept')->default(true);
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
a ver si me podéis decir por donde atacar, la verdad es que estoy un poco liado, la verdad es que estoy un poco liado con Laravel.