PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Question By
Unsolved

What's the best way to present forms and tools to paid users

solutions

Mar 11th, 2023 09:23 PM

I am not sure how to go about presenting the following

  1. a way for the user to submit task (form fields), we get a notification and once we complete task we change status to completed
  2. integrate openai for the user to use chatgpt3
  3. They can export results
  4. Integrate zoom calls where only paid users can attend

Will I use routes? BREAD? pages? Any pointers will be truly appreciated

bobbyiliev

Mar 12th, 2023 07:50 AM

Hi there,

There are a few things that I could suggest:

  • For OpenAI, you could use the following PHP package:

https://github.com/openai-php/client

It comes with a chat helper method as well:

$response = $client->chat()->create([
    'model' => 'gpt-3.5-turbo',
    'messages' => [
        ['role' => 'user', 'content' => 'Hello!'],
    ],
]);

$response->id; // 'chatcmpl-6pMyfj1HF4QXnfvjtfzvufZSQq6Eq'
$response->object; // 'chat.completion'
$response->created; // 1677701073
$response->model; // 'gpt-3.5-turbo-0301'

foreach ($response->choices as $result) {
    $result->index; // 0
    $result->message->role; // 'assistant'
    $result->message->content; // '\n\nHello there! How can I assist you today?'
    $result->finishReason; // 'stop'
}

$response->usage->promptTokens; // 9,
$response->usage->completionTokens; // 12,
$response->usage->totalTokens; // 21

$response->toArray(); // ['id' => 'chatcmpl-6pMyfj1HF4QXnfvjtfzvufZSQq6Eq', ...]

For exporting the results, you can create a Controller with an export method using Laravel's Eloquent ORM:

use App\Models\Task; // Replace 'Task' with the name of your model

public function exportToCsv()
{
    // Retrieve the data you want to export using Eloquent
    $tasks = Task::where('user_id', auth()->user()->id)->get();

    // Define the file name and path for the CSV file
    $filename = auth()->user()->id) . "tasks.csv";
    $filepath = storage_path('app/'.$filename);

    // Open a file pointer to the CSV file
    $file = fopen($filepath, 'w');

    // Write the headers for the CSV file
    fputcsv($file, ['ID', 'Title', 'Description', 'Status']);

    // Write the data for each task to the CSV file
    foreach ($tasks as $task) {
        fputcsv($file, [$task->id, $task->title, $task->description, $task->status]);
    }

    // Close the file pointer
    fclose($file);

    // Return the CSV file as a download
    return response()->download($filepath, $filename);
}

This is just one suggestion, feel free to modify and improve the logic as needed.

You can use the standard Laravel from builder to achieve the task submissions:

Laravel Forms

To integration Zoom links, what you could do is to just create a Zoom Link component and only display it if the user is a pro one:

@if(auth()->user()->role == 'premium')
    // Your Zoom link here
@endif

Hope that this helps.

Best,

Bobby

solutions

Mar 13th, 2023 05:15 AM

Thank you so much for the guidance! I am new in laravel so I am going through the SAAS academy to get a better understanding

bobbyiliev

Mar 13th, 2023 06:08 AM

No problem! Happy to help!