obsidian777's avatar

Folder view Help

How would I go about creating a "folders view" in my application? Im not talking about dealing with the folders associated with laravel but organizing files in my actual web application. All data will be hosted on a server. I want the user to create a Job and that job would have many files. I want the user to be able to organize their jobs.

Is using folders the best way for the user to organize all the jobs?

0 likes
8 replies
LaryAI's avatar
Level 58

To create a "folders view" in your application where users can organize jobs and their associated files, you can follow these steps. This solution assumes you are using Laravel for your backend and a frontend framework like Vue.js for the user interface.

Step 1: Define Your Database Schema

First, you need to define the database schema for jobs and files. Each job can have multiple files, so you will have a one-to-many relationship between jobs and files.

// Create a migration for jobs
php artisan make:migration create_jobs_table --create=jobs

// In the migration file
Schema::create('jobs', function (Blueprint $table) {
    $table->id();
    $table->string('name');
    $table->timestamps();
});

// Create a migration for files
php artisan make:migration create_files_table --create=files

// In the migration file
Schema::create('files', function (Blueprint $table) {
    $table->id();
    $table->foreignId('job_id')->constrained()->onDelete('cascade');
    $table->string('filename');
    $table->timestamps();
});

Step 2: Define Models and Relationships

Next, define the models and their relationships.

Step 3: Create Controllers

Create controllers to handle the CRUD operations for jobs and files.

Step 4: Define Routes

Define the routes for your controllers.

// web.php or api.php
use App\Http\Controllers\JobController;
use App\Http\Controllers\FileController;

Route::apiResource('jobs', JobController::class);
Route::post('files', [FileController::class, 'store']);
Route::delete('files/{id}', [FileController::class, 'destroy']);

Step 5: Create the Frontend

For the frontend, you can use Vue.js to create a user interface where users can create jobs and upload files.

Conclusion

This solution provides a basic structure for creating a "folders view" in your application. Users can create jobs and upload files associated with those jobs. You can expand this further by adding more features like file uploads, drag-and-drop functionality, and more advanced UI components.

vincent15000's avatar

Are you talking about real Laravel jobs (I mean the Job class) or something else ?

I don't understand why the users would have to organize jobs inside folders, unless it's not Laravel jobs.

1 like
obsidian777's avatar

@vincent15000 Not the laravel jobs. I knew I should have named them something different.

The program calculates brace loads for buildings. I want an easy way for the user to organize all the calculations into a folders view. Just not sure thats the best way to go about it.

Tray2's avatar

Why use files, you can store the data in the database. Any and all binary files should be stored on the file system with paths stored in the database.

2 likes
obsidian777's avatar

@Tray2 Looking for a way for the end user to be able to organize their view the files.

Sorry im both very new and all my search results end up talking about laravel application folder organization and not views for end users.

1 like
Tray2's avatar

@obsidian777 Still the same answer, the calculations should be kept in the database, and you can create "folders" in the database as well, just add a folders table and give the calculation a folder_id.

2 likes
obsidian777's avatar

@Tray2 Thanks. That how I have it set up now. Just wasnt sure I was going about things correctly.

2 likes

Please or to participate in this conversation.