vendredi 27 avril 2018

Storing social profiles in a database field Laravel

In an application I'm building I have a migration for a Profiles table as defined below:

public function up()
    {
        Schema::create('profiles', function (Blueprint $table) {
            $table->increments('id');
            $table->string('user_username');
            $table->mediumText('skills')->nullable();
            $table->mediumText('background')->nullable();
            $table->string('socialProfiles')->nullable();
            $table->string('displayPicture')->default('../../assets/images/user_pic.jpg');
            $table->string('mangedByUsername')->nullable();
            $table->boolean('changesPending')->default(0);
            $table->timestamps();
        });
    }

One of these fields is called socialProfiles. In this field, I'm thinking of having an array similar to the following:

$profile['Twitter'] = "URL";
$profile['Twitter'] = "URL";

Within the field, if possible?

So that when I initially create the profile, it initialises the array and then when a user types a URL in the corresponding text box and hits save, the URL is put in the correct position in the array.

Alternatively, I was going to use a social profiles table and reference the user id but surely this is overkill?

If anyone has approached this before, how did you solve it?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire