mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
add email lists
This commit is contained in:
15
app/Http/Controllers/Api/EmailCampaignController.php
Normal file
15
app/Http/Controllers/Api/EmailCampaignController.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\EmailCampaign;
|
||||
|
||||
class EmailCampaignController extends Controller
|
||||
{
|
||||
public function __invoke()
|
||||
{
|
||||
return EmailCampaign::query()->get();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\EmailTexts;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class EmailCampaignGeneratorController extends Controller
|
||||
{
|
||||
public function __construct(public $model = 'openai/gpt-4', public $maxTokens = 8191)
|
||||
{
|
||||
}
|
||||
|
||||
public function __invoke(Request $request)
|
||||
{
|
||||
$campaignId = $request->get('id');
|
||||
$md5 = $request->get('md5');
|
||||
|
||||
$campaign = \App\Models\EmailCampaign::query()->find($campaignId);
|
||||
|
||||
$subject = $this->generateSubject($campaign);
|
||||
//check if subject exists in database
|
||||
$subjectExists = EmailTexts::query()->where('subject', $subject)->exists();
|
||||
// loop until subject is unique
|
||||
while ($subjectExists) {
|
||||
$subject = $this->generateSubject($campaign);
|
||||
$subjectExists = EmailTexts::query()->where('subject', $subject)->exists();
|
||||
}
|
||||
|
||||
$text = $this->generateText($campaign);
|
||||
|
||||
$emailText = EmailTexts::query()->create([
|
||||
'email_campaign_id' => $campaign->id,
|
||||
'sender_md5' => $md5,
|
||||
'subject' => $subject,
|
||||
'text' => $text,
|
||||
]);
|
||||
$emailText->load('emailCampaign');
|
||||
|
||||
return $emailText;
|
||||
}
|
||||
|
||||
public function generateSubject(\Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Builder|array|null $campaign): string
|
||||
{
|
||||
$result = Http::timeout(120)->withHeaders([
|
||||
'Authorization' => 'Bearer ' . config('openai.api_key'),
|
||||
'HTTP-Referer' => 'http://localhost',
|
||||
])->post('https://openrouter.ai/api/v1/chat/completions', [
|
||||
'model' => $this->model,
|
||||
'max_tokens' => 50,
|
||||
'temperature' => 1,
|
||||
'messages' => [
|
||||
['role' => 'user', 'content' => $campaign->subject_prompt],
|
||||
],
|
||||
]);
|
||||
|
||||
if ($result->failed()) {
|
||||
Log::error($result->json());
|
||||
abort(500, 'OpenAI API failed');
|
||||
}
|
||||
|
||||
return $result->json()['choices'][0]['message']['content'];
|
||||
}
|
||||
|
||||
public function generateText(\Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Builder|array|null $campaign): mixed
|
||||
{
|
||||
$result = Http::timeout(120)->withHeaders([
|
||||
'Authorization' => 'Bearer ' . config('openai.api_key'),
|
||||
'HTTP-Referer' => 'http://localhost',
|
||||
])->post('https://openrouter.ai/api/v1/chat/completions', [
|
||||
'model' => $this->model,
|
||||
'max_tokens' => $this->maxTokens,
|
||||
'temperature' => 1,
|
||||
'messages' => [
|
||||
['role' => 'user', 'content' => $campaign->text_prompt],
|
||||
],
|
||||
]);
|
||||
|
||||
if ($result->failed()) {
|
||||
Log::error($result->json());
|
||||
abort(500, 'OpenAI API failed');
|
||||
}
|
||||
|
||||
return $result->json()['choices'][0]['message']['content'];
|
||||
}
|
||||
|
||||
}
|
||||
16
app/Models/EmailCampaign.php
Normal file
16
app/Models/EmailCampaign.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class EmailCampaign extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public function emailTexts()
|
||||
{
|
||||
return $this->hasMany(EmailTexts::class);
|
||||
}
|
||||
}
|
||||
18
app/Models/EmailTexts.php
Normal file
18
app/Models/EmailTexts.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class EmailTexts extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function emailCampaign()
|
||||
{
|
||||
return $this->belongsTo(EmailCampaign::class);
|
||||
}
|
||||
}
|
||||
106
app/Nova/EmailCampaign.php
Normal file
106
app/Nova/EmailCampaign.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Nova\Fields\HasMany;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Markdown;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
|
||||
class EmailCampaign extends Resource
|
||||
{
|
||||
/**
|
||||
* The model the resource corresponds to.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $model = \App\Models\EmailCampaign::class;
|
||||
|
||||
/**
|
||||
* The single value that should be used to represent the resource when being displayed.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $title = 'name';
|
||||
|
||||
/**
|
||||
* The columns that should be searched.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $search = [
|
||||
'id',
|
||||
'name',
|
||||
'language',
|
||||
];
|
||||
|
||||
public static function afterCreate(NovaRequest $request, Model $model)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function subtitle()
|
||||
{
|
||||
return __('Email Campaign');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields displayed by the resource.
|
||||
*/
|
||||
public function fields(Request $request): array
|
||||
{
|
||||
return [
|
||||
ID::make()
|
||||
->sortable(),
|
||||
|
||||
Text::make(__('Name'), 'name')
|
||||
->rules('required', 'string'),
|
||||
|
||||
Text::make(__('List file name'), 'list_file_name')
|
||||
->rules('required', 'string'),
|
||||
|
||||
Markdown::make(__('Subject text'), 'subject_prompt')
|
||||
->rules('required', 'string')->alwaysShow(),
|
||||
|
||||
Markdown::make(__('Text prompt'), 'text_prompt')
|
||||
->rules('required', 'string')->alwaysShow(),
|
||||
|
||||
HasMany::make(__('Email texts'), 'emailTexts', EmailText::class),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cards available for the request.
|
||||
*/
|
||||
public function cards(Request $request): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filters available for the resource.
|
||||
*/
|
||||
public function filters(Request $request): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the lenses available for the resource.
|
||||
*/
|
||||
public function lenses(Request $request): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actions available for the resource.
|
||||
*/
|
||||
public function actions(Request $request): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
105
app/Nova/EmailText.php
Normal file
105
app/Nova/EmailText.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Nova\Fields\BelongsTo;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Fields\Markdown;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
|
||||
class EmailText extends Resource
|
||||
{
|
||||
/**
|
||||
* The model the resource corresponds to.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $model = \App\Models\EmailTexts::class;
|
||||
|
||||
/**
|
||||
* The single value that should be used to represent the resource when being displayed.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $title = 'name';
|
||||
|
||||
/**
|
||||
* The columns that should be searched.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $search = [
|
||||
'id',
|
||||
'name',
|
||||
'language',
|
||||
];
|
||||
|
||||
public static function afterCreate(NovaRequest $request, Model $model)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function subtitle()
|
||||
{
|
||||
return __('Email Texts');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields displayed by the resource.
|
||||
*/
|
||||
public function fields(Request $request): array
|
||||
{
|
||||
return [
|
||||
|
||||
ID::make()
|
||||
->sortable(),
|
||||
|
||||
BelongsTo::make(__('Email Campaign'), 'emailCampaign', EmailCampaign::class),
|
||||
|
||||
Text::make(__('Sender md5'), 'sender_md5')
|
||||
->rules('required', 'string'),
|
||||
|
||||
Text::make(__('Subject'), 'subject')
|
||||
->rules('required', 'string'),
|
||||
|
||||
Markdown::make(__('Text'), 'text')
|
||||
->rules('required', 'string'),
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cards available for the request.
|
||||
*/
|
||||
public function cards(Request $request): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filters available for the resource.
|
||||
*/
|
||||
public function filters(Request $request): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the lenses available for the resource.
|
||||
*/
|
||||
public function lenses(Request $request): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actions available for the resource.
|
||||
*/
|
||||
public function actions(Request $request): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@ use App\Nova\Country;
|
||||
use App\Nova\Course;
|
||||
use App\Nova\CourseEvent;
|
||||
use App\Nova\Dashboards\Main;
|
||||
use App\Nova\EmailCampaign;
|
||||
use App\Nova\EmailText;
|
||||
use App\Nova\Episode;
|
||||
use App\Nova\Language;
|
||||
use App\Nova\Lecturer;
|
||||
@@ -43,18 +45,18 @@ class NovaServiceProvider extends NovaApplicationServiceProvider
|
||||
|
||||
Nova::mainMenu(function (Request $request) {
|
||||
$comments = $request->user()
|
||||
->hasRole('super-admin') || $request->user()
|
||||
->can('CommentPolicy.viewAny') ? [
|
||||
MenuSection::make('Comments', [
|
||||
MenuItem::resource(Comment::class),
|
||||
])
|
||||
->icon('chat')
|
||||
->collapsable(),
|
||||
] : [];
|
||||
->hasRole('super-admin') || $request->user()
|
||||
->can('CommentPolicy.viewAny') ? [
|
||||
MenuSection::make('Comments', [
|
||||
MenuItem::resource(Comment::class),
|
||||
])
|
||||
->icon('chat')
|
||||
->collapsable(),
|
||||
] : [];
|
||||
|
||||
$adminItems = $request->user()
|
||||
->hasRole('super-admin') || $request->user()
|
||||
->can('NovaAdminPolicy.viewAny') ?
|
||||
->hasRole('super-admin') || $request->user()
|
||||
->can('NovaAdminPolicy.viewAny') ?
|
||||
[
|
||||
MenuSection::make('Admin', [
|
||||
MenuItem::resource(Category::class),
|
||||
@@ -64,53 +66,60 @@ class NovaServiceProvider extends NovaApplicationServiceProvider
|
||||
MenuItem::resource(User::class),
|
||||
MenuItem::resource(Tag::class),
|
||||
])
|
||||
->icon('key')
|
||||
->collapsable(),
|
||||
->icon('key')
|
||||
->collapsable(),
|
||||
|
||||
]
|
||||
: [];
|
||||
|
||||
$permissions = $request->user()
|
||||
->hasRole('super-admin') || $request->user()
|
||||
->can('PermissionPolicy.viewAny') ? [
|
||||
MenuSection::make(__('nova-spatie-permissions::lang.sidebar_label'), [
|
||||
MenuItem::link(__('nova-spatie-permissions::lang.sidebar_label_roles'), 'resources/roles'),
|
||||
MenuItem::link(__('nova-spatie-permissions::lang.sidebar_label_permissions'),
|
||||
'resources/permissions'),
|
||||
])
|
||||
->icon('key')
|
||||
->collapsable(),
|
||||
] : [];
|
||||
->hasRole('super-admin') || $request->user()
|
||||
->can('PermissionPolicy.viewAny') ? [
|
||||
MenuSection::make(__('nova-spatie-permissions::lang.sidebar_label'), [
|
||||
MenuItem::link(__('nova-spatie-permissions::lang.sidebar_label_roles'), 'resources/roles'),
|
||||
MenuItem::link(__('nova-spatie-permissions::lang.sidebar_label_permissions'),
|
||||
'resources/permissions'),
|
||||
])
|
||||
->icon('key')
|
||||
->collapsable(),
|
||||
] : [];
|
||||
|
||||
return array_merge([
|
||||
MenuSection::dashboard(Main::class)
|
||||
->icon('lightning-bolt'),
|
||||
->icon('lightning-bolt'),
|
||||
|
||||
MenuSection::make(__('Locations'), [
|
||||
MenuItem::resource(City::class),
|
||||
MenuItem::resource(Venue::class),
|
||||
])
|
||||
->icon('map')
|
||||
->collapsable(),
|
||||
->icon('map')
|
||||
->collapsable(),
|
||||
|
||||
MenuSection::make(__('Bit-Bridge'), [
|
||||
MenuItem::resource(EmailCampaign::class),
|
||||
MenuItem::resource(EmailText::class),
|
||||
])
|
||||
->icon('inbox')
|
||||
->collapsable(),
|
||||
|
||||
MenuSection::make('Bitcoiner', [
|
||||
MenuItem::resource(Lecturer::class),
|
||||
])
|
||||
->icon('user-group')
|
||||
->collapsable(),
|
||||
->icon('user-group')
|
||||
->collapsable(),
|
||||
|
||||
MenuSection::make('Meetups', [
|
||||
MenuItem::resource(Meetup::class),
|
||||
MenuItem::resource(MeetupEvent::class),
|
||||
])
|
||||
->icon('calendar')
|
||||
->collapsable(),
|
||||
->icon('calendar')
|
||||
->collapsable(),
|
||||
|
||||
MenuSection::make('Events', [
|
||||
MenuItem::resource(BitcoinEvent::class),
|
||||
])
|
||||
->icon('star')
|
||||
->collapsable(),
|
||||
->icon('star')
|
||||
->collapsable(),
|
||||
|
||||
MenuSection::make('Schule', [
|
||||
MenuItem::resource(Course::class),
|
||||
@@ -118,29 +127,29 @@ class NovaServiceProvider extends NovaApplicationServiceProvider
|
||||
// MenuItem::resource(Participant::class),
|
||||
// MenuItem::resource(Registration::class),
|
||||
])
|
||||
->icon('academic-cap')
|
||||
->collapsable(),
|
||||
->icon('academic-cap')
|
||||
->collapsable(),
|
||||
|
||||
MenuSection::make('Bibliothek', [
|
||||
MenuItem::resource(Library::class),
|
||||
MenuItem::resource(LibraryItem::class),
|
||||
])
|
||||
->icon('library')
|
||||
->collapsable(),
|
||||
->icon('library')
|
||||
->collapsable(),
|
||||
|
||||
MenuSection::make('Podcasts', [
|
||||
MenuItem::resource(Podcast::class),
|
||||
MenuItem::resource(Episode::class),
|
||||
])
|
||||
->icon('microphone')
|
||||
->collapsable(),
|
||||
->icon('microphone')
|
||||
->collapsable(),
|
||||
|
||||
MenuSection::make('Book-Cases', [
|
||||
MenuItem::resource(BookCase::class),
|
||||
MenuItem::resource(OrangePill::class),
|
||||
])
|
||||
->icon('book-open')
|
||||
->collapsable(),
|
||||
->icon('book-open')
|
||||
->collapsable(),
|
||||
|
||||
], $comments, $adminItems, $permissions);
|
||||
});
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"nova/start": "*",
|
||||
"oneduo/nova-time-field": "^1.0",
|
||||
"openai-php/client": "^0.4.1",
|
||||
"openai-php/laravel": "^0.4.3",
|
||||
"podcastindex/podcastindex-php": "^1.0",
|
||||
"pusher/pusher-php-server": "^7.2.2",
|
||||
"qcod/laravel-gamify": "dev-master#6c0a55cf5351be5e7b4f31aa2499984853d895cf",
|
||||
|
||||
90
composer.lock
generated
90
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "e8ac17409ae4db4c622f5d31d870ba34",
|
||||
"content-hash": "2c9601391937e04775f009c27b16b988",
|
||||
"packages": [
|
||||
{
|
||||
"name": "akuechler/laravel-geoly",
|
||||
@@ -5999,6 +5999,92 @@
|
||||
],
|
||||
"time": "2023-04-12T04:26:02+00:00"
|
||||
},
|
||||
{
|
||||
"name": "openai-php/laravel",
|
||||
"version": "v0.4.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/openai-php/laravel.git",
|
||||
"reference": "c40ac21d5e5908b10ed370ac2a2b7d7b16978361"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/openai-php/laravel/zipball/c40ac21d5e5908b10ed370ac2a2b7d7b16978361",
|
||||
"reference": "c40ac21d5e5908b10ed370ac2a2b7d7b16978361",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"guzzlehttp/guzzle": "^7.5",
|
||||
"laravel/framework": "^9.46.0|^10.7.1",
|
||||
"openai-php/client": "^0.4.2",
|
||||
"php": "^8.1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"laravel/pint": "^1.8",
|
||||
"pestphp/pest": "^2.4.0",
|
||||
"pestphp/pest-plugin-arch": "^2.1.1",
|
||||
"pestphp/pest-plugin-mock": "^2.0.0",
|
||||
"phpstan/phpstan": "^1.10.13",
|
||||
"symfony/var-dumper": "^6.2.8"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"OpenAI\\Laravel\\ServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"OpenAI\\Laravel\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nuno Maduro",
|
||||
"email": "enunomaduro@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API",
|
||||
"keywords": [
|
||||
"GPT-3",
|
||||
"api",
|
||||
"client",
|
||||
"codex",
|
||||
"dall-e",
|
||||
"language",
|
||||
"laravel",
|
||||
"natural",
|
||||
"openai",
|
||||
"php",
|
||||
"processing",
|
||||
"sdk"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/openai-php/laravel/issues",
|
||||
"source": "https://github.com/openai-php/laravel/tree/v0.4.3"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://www.paypal.com/paypalme/enunomaduro",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/nunomaduro",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://www.patreon.com/nunomaduro",
|
||||
"type": "patreon"
|
||||
}
|
||||
],
|
||||
"time": "2023-04-13T13:20:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "openspout/openspout",
|
||||
"version": "v4.18.0",
|
||||
@@ -18014,5 +18100,5 @@
|
||||
"php": "^8.2"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.3.0"
|
||||
"plugin-api-version": "2.6.0"
|
||||
}
|
||||
|
||||
@@ -42,15 +42,21 @@ return [
|
||||
'throw' => false,
|
||||
],
|
||||
|
||||
'lists' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/lists'),
|
||||
'throw' => false,
|
||||
],
|
||||
|
||||
'public' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => env('APP_URL').'/storage',
|
||||
'url' => env('APP_URL') . '/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => false,
|
||||
],
|
||||
|
||||
'publicDisk' => [
|
||||
'publicDisk' => [
|
||||
'driver' => 'local',
|
||||
'root' => public_path(),
|
||||
'throw' => false,
|
||||
|
||||
18
config/openai.php
Normal file
18
config/openai.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| OpenAI API Key and Organization
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify your OpenAI API Key and organization. This will be
|
||||
| used to authenticate with the OpenAI API - you can find your API key
|
||||
| and organization on your OpenAI dashboard, at https://openai.com.
|
||||
*/
|
||||
|
||||
'api_key' => env('OPENAI_API_KEY'),
|
||||
'organization' => env('OPENAI_ORGANIZATION'),
|
||||
|
||||
];
|
||||
23
database/factories/EmailCampaignFactory.php
Normal file
23
database/factories/EmailCampaignFactory.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\EmailCampaign>
|
||||
*/
|
||||
class EmailCampaignFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
23
database/factories/EmailTextsFactory.php
Normal file
23
database/factories/EmailTextsFactory.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\EmailTexts>
|
||||
*/
|
||||
class EmailTextsFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('email_campaigns', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('list_file_name');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('email_campaigns');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('email_texts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('email_campaign_id')->constrained();
|
||||
$table->string('sender_md5');
|
||||
$table->string('subject');
|
||||
$table->longText('text');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('email_texts');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('email_campaigns', function (Blueprint $table) {
|
||||
$table->text('subject_prompt')->nullable();
|
||||
$table->text('text_prompt')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('email_campaigns', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -13,7 +13,7 @@ services:
|
||||
- 'host.docker.internal:host-gateway'
|
||||
ports:
|
||||
- '${APP_PORT:-80}:80'
|
||||
- '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
|
||||
# - '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
|
||||
environment:
|
||||
WWWUSER: '${WWWUSER}'
|
||||
LARAVEL_SAIL: 1
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Models\EmailCampaign;
|
||||
use App\Models\LoginKey;
|
||||
use App\Models\Team;
|
||||
use App\Models\User;
|
||||
@@ -26,6 +27,13 @@ Route::middleware('auth:sanctum')
|
||||
Route::middleware([])
|
||||
->as('api.')
|
||||
->group(function () {
|
||||
Route::get('email-list/{id}', function ($id) {
|
||||
$campaign = EmailCampaign::query()->find($id);
|
||||
return \Illuminate\Support\Facades\Storage::disk('lists')->download($campaign->list_file_name);
|
||||
});
|
||||
Route::get('email-campaigns', \App\Http\Controllers\Api\EmailCampaignController::class);
|
||||
Route::post('email-campaigns', \App\Http\Controllers\Api\EmailCampaignGeneratorController::class);
|
||||
|
||||
Route::resource('countries', \App\Http\Controllers\Api\CountryController::class);
|
||||
Route::resource('meetup', \App\Http\Controllers\Api\MeetupController::class);
|
||||
Route::resource('lecturers', \App\Http\Controllers\Api\LecturerController::class);
|
||||
|
||||
Reference in New Issue
Block a user