Can you repeat again what is your question?
Store files and "attach" them to an user
Hi,
I'm developing an app that is supposed to manage training applications for futur students.
I have to allow applicant to upload several files (CV, cover letter, ...). I'm currently looking for a way to store those files (Flysystem), and more importantly to "attach" those files to an user. I would like each user to only have access to their files and be able to manage them (upload, delete, view).
I'm rather a beginner on Laravel (mainly doing CRUD app that only need a db) and I encounter difficulties designing a solution to my problem.
Thanks.
PS: This is a school project so my app doesn't need to be super optimized and fully secured.
Hello,
You need another table make another migration for create a new table. If you store on your website you can use this cmd : php artisan storage:link, and after that go to migration example
Schema::create(
'file_students', function (Blueprint $table) {
$table->id();
$table->string('path');
$table->bigInteger('user_id')->unique()->unsigned();
//this will able you to fetch the file of you user_id,
//user_id represent the id of the table users. If you
// want to get the id of an user what is connected you
//need to use auth()->user()->id; on the mass
//assignement.
$table->timestamps();
}
);
The path is the directory suite to find the files in your project. example in database image/feafjzaefzefa.png,
You also need to use the {{ asset('folder_who_file_is_stored'.$images_find_by_user_id) }}
hope this help.
Please or to participate in this conversation.