mirror of https://github.com/pixelfed/pixelfed
Add profile model, migration and controller
Also added User model observer to create a profile when a new user is created.pull/9/head
parent
2855c83c50
commit
9dd58c5abd
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ProfileController extends Controller
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Observers;
|
||||||
|
|
||||||
|
use App\{Profile, User};
|
||||||
|
|
||||||
|
class UserObserver
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Listen to the User created event.
|
||||||
|
*
|
||||||
|
* @param \App\User $user
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function saved(User $user)
|
||||||
|
{
|
||||||
|
if($user->has('profile')->count() == 0) {
|
||||||
|
$profile = new Profile;
|
||||||
|
$profile->user_id = $user->id;
|
||||||
|
$profile->username = $user->username;
|
||||||
|
$profile->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Profile extends Model
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateProfilesTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('profiles', function (Blueprint $table) {
|
||||||
|
$table->increments('id');
|
||||||
|
$table->unsignedInteger('user_id')->nullable();
|
||||||
|
$table->string('username')->nullable()->unique()->index();
|
||||||
|
$table->string('name')->nullable();
|
||||||
|
$table->string('bio', 150)->nullable();
|
||||||
|
$table->string('location')->nullable();
|
||||||
|
$table->string('website')->nullable();
|
||||||
|
$table->string('remote_url')->nullable();
|
||||||
|
$table->text('keybase_proof')->nullable();
|
||||||
|
$table->boolean('is_private')->default(false);
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('profiles');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue