Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Saadc06's avatar

sending forms bitween users

I have made two types of users in my auth system ; Admin and a normal user, I want the user to be able to fill up a form and send it to the admin so it will appear on the admin's dashboard when he choses the the user in question

how can i add this feature?

0 likes
1 reply
Thyrosis's avatar

I don't have any experience with Envoyer, but isn't this just a case of storing the users form-answers in a database and pull them up when the admin views the user profile?


# Migration
class CreateFormsTable extends Migration
{
    public function up()
    {
        Schema::create(forms, function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('user_id');
            $table->json('answers');
            $table->timestamps();
        });
    }
}

# User class
class User
{
    public function forms()
    {
        return $this->hasMany(Form::class);
    }
}

# Form class
class Form
{
    protected $casts = [
        'answers' => 'array'
    ];

    public function user()
    {
        return $this->belongsTo(User::class);
    }
}

# Admin controller to show user profile
public function show(User $user)
{
    return $user->forms->answers;
}


Please or to participate in this conversation.