Configure your platform
You can install the package via composer:
composer require envor/platform
You can publish the config file with:
php artisan vendor:publish --tag="platform-config"
This is the contents of the published config file(s):
// config/database.php
return [
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
|--------------------------------------------------------------------------
|
| Here you may specify which of the database connections below you wish
| to use as your default connection for all database work. Of course
| you may use many connections at once throughout the application.
|
*/
'platform' => env('PLATFORM_DB_CONNECTION', 'sqlite'),
'default' => env('DB_CONNECTION', 'sqlite'),
];
// config/auth.php
return [
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_reset_tokens',
'connection' => env('PLATFORM_DB_CONNECTION', 'sqlite'),
'expire' => 60,
'throttle' => 60,
],
],
];
// config/platform.php
return [
'landing_page_disk' => env('LANDING_PAGE_DISK', 'public'),
'profile_photo_disk' => env('PROFILE_PHOTO_DISK', 'public'),
'stores_contact_info' => env('STORES_CONTACT_INFO', true),
'empty_logo_path' => 'profile-photos/no_image.jpg',
'empty_phone' => '(_ _ _) _ _ _- _ _ _ _',
'empty_fax' => '(_ _ _) _ _ _- _ _ _ _',
'logo_path' => env('PLATFORM_LOGO_PATH'),
'name' => env('PLATFORM_NAME'),
'phone' => env('PLATFORM_PHONE_NUMBER'),
'fax' => env('PLATFORM_FAX_NUMBER'),
'street_address' => env('PLATFORM_STREET_ADDRESS'),
'city_state_zip' => env('PLATFORM_CITY_STATE_ZIP'),
'email' => env('PLATFORM_EMAIL'),
];
// config/session.php
<?php
return [
'connection' => env('PLATFORM_DB_CONNECTION'),
];
Add the trait Envor\Platform\UsesPlatformConnection
to your model:
class Business extends Model
{
use \Envor\Platform\UsesPlatformConnection;
}
Add the uuid
column to your model's table in a migration:
$table->uuid('uuid')->index()->unique();
Add the trait Envor\Platform\UsesPlatformUuids
to your model:
class Business extends Model
{
use \Envor\Platform\HasPlatformUuids;
}
Allows a model to have a logo, which can be updoaded, deleted and replaced by the user.
- Add
profile_photo_path
(string) field to your model's database table
$table->text('profile_photo_path')->nullable();
- Add
\Envor\Platform\HasProfilePhoto
trait to your model.
It can be any model but we will use the user model as an example.
...
class User extends Authenticatable
{
...
use \Envor\Platform\HasProfilePhoto;
...
}
Usage example
$user->updateProfilePhoto($request->file('photo'));
<img src="{{ $user->profile_photo_url }}" alt="{{ $user->name }}" class="rounded-full h-20 w-20 object-cover">
- Use the form (optional)
Note
Requires livewire/volt and tailwind.
composer require livewire/volt
php artisan volt:install
Now you can add the form to any view:
@livewire('update-logo-form', ['model' => auth()->user()])
Screenshot:
Allows a model to have an html "landing page", which can be uploaded, deleted and replaced by the user.
- publish and run migration
This will create a landing_pages
table where landing page paths and relationship info will be stored.
php artisan vendor:publish --tag='platform-migrations'
php artisan migrate --path=database/migrations/platform
- Add
\Envor\Platform\HasLandingPage
trait to your model.
It can be any model but we will use the user model as an example:
...
class User extends Authenticatable
{
...
use \Envor\Platform\HasLandingPage;
...
}
Usage example
$user->updateLandingPage($request->file('landing-page'));
<a href="{{ $user->url }}">Visit Landing Page</a>
- Use the form (optional)
Note
Requires livewire/volt and tailwind.
composer require livewire/volt
php artisan volt:install
Now you can add the form to any view:
@livewire('update-landing-page-form', ['model' => auth()->user()])
Screenshot:
- Make The landing page the home page (optional)
In this example we will illustrate how it might be done for a user which has a domain
property.
Add domain field to users table in a migration:
$table->string('domain')->nullable();
Then show the page on the home '/' route:
use Illuminate\Http\Request;
Route::get('/', function (Request $request) {
$user = \App\Models\User::where('domain', $request->getHost())->first();
if ($user?->landingPage) {
return response()->file(Storage::disk($user->landingPageDisk())->path($user->landingPagePath()));
}
return view('welcome');
})->name('home');
Allows a model to have address and other contact details
- Add contact data text (or json) field to your model's database table
$table->text('contact_data')->nullable();
- Add
\Envor\Platform\HasContactData
trait to your model.
It can be any model but we will use the user model as an example:
...
class User extends Authenticatable
{
...
use \Envor\Platform\HasContactData;
...
}
Usage example
$user->updateContactData([
'name' => 'Jane Doe',
'address' => [
'1234 somewhere lane'
];
]);
- Use form (optional)
Note
Requires livewire/volt and tailwind.
composer require livewire/volt
php artisan volt:install
Now you can add the form to any view:
@livewire('update-contact-info-form', ['model' => $user, 'readonly' => $user->id != auth()->id()])
Screenshot:
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.