Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mlantz committed Apr 24, 2024
2 parents 38ed14f + 2faf6bd commit 53b896a
Show file tree
Hide file tree
Showing 33 changed files with 34,860 additions and 29,885 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
@@ -0,0 +1,2 @@
.git
.env
72 changes: 72 additions & 0 deletions .env.docker
@@ -0,0 +1,72 @@
APP_NAME="Grafite Scaffold"
APP_ENV=local
APP_KEY=base64:tUx23rtiQsNZtV4aRH38ofndb8lX05LWZaSXUYe+F/4=
APP_DEBUG=true
APP_URL="https://scaffold.local.test/"

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=scaffold
DB_USERNAME=sail
DB_PASSWORD=password

BROADCAST_DRIVER=pusher
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_CLIENT=phpredis
REDIS_HOST=redis
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=Scaffold
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=hello@scaffold.com
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=1160273
PUSHER_APP_KEY=beda029944f4b5d0809b
PUSHER_APP_SECRET=89286a9097669f0c48ff
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

PLAN_MONTHLY=plan_FgRNFn5SPrDG6g
PLAN_YEARLY=plan_Gb9YKx6eWjjApR

STRIPE_KEY=pk_test_zVmnUpEu5wX5bi3e9HETz4Zn
STRIPE_SECRET=sk_test_k446eRvPjUZHNUIELSMyNS3t
CASHIER_PAYMENT_NOTIFICATION=Laravel\Cashier\Notifications\ConfirmPayment

HONEYPOT_NAME=my_email
SANCTUM_STATEFUL_DOMAINS="scaffold.local.test,localhost,127.0.0.1,127.0.0.1:8000,::1"
SESSION_DOMAIN="scaffold.local.test"

MISSION_CONTROL_URL='https://missioncontrol.test'
MISSION_CONTROL_USER_TOKEN="6|SDYLxDrSdt8S16gTRuumdbkE5Isle43rlkoPo6UB"
MISSION_CONTROL_PROJECT_KEY="37deb93ec12fe69e5cb0c55dc4d5f544"
MISSION_CONTROL_PROJECT_UUID="fee11c7f-316e-4288-9cf3-3167b43c80fc"

REGISTRATION=true

APP_PORT=48080
FORWARD_DB_PORT=43306
FORWARD_REDIS_PORT=46379
FORWARD_MEILISEARCH_PORT=47700
FORWARD_MAILHOG_PORT=41025
FORWARD_MAILHOG_DASHBOARD_PORT=48025
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,6 +4,7 @@
/storage/*.key
/vendor
.env
.env.docker
.phpunit.result.cache
/.phpunit.cache
/.phpunit.cache/test-results
Expand Down
2 changes: 1 addition & 1 deletion .phpunit.cache/test-results

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
----

## [v2.19.0] - 2024-04-24

### Added
- Laravel 11 support

### Changed
- Some minor ajax stuff
- Improved security headers
- Started dockerizing

## [v2.18.0] - 2024-01-08

### Changed
Expand Down
22 changes: 22 additions & 0 deletions Dockerfile
@@ -0,0 +1,22 @@
FROM composer:2.0 as build
COPY . /app/
RUN composer install --prefer-dist --no-dev --optimize-autoloader --no-interaction

FROM php:8.1-apache-buster as production

ENV APP_ENV=production
ENV APP_DEBUG=false

RUN docker-php-ext-configure opcache --enable-opcache && \
docker-php-ext-install pdo pdo_mysql
COPY docker/php/conf.d/opcache.ini /usr/local/etc/php/conf.d/opcache.ini

COPY --from=build /app /var/www/html
COPY docker/000-default.conf /etc/apache2/sites-available/000-default.conf
COPY .env.prod /var/www/html/.env

RUN php artisan config:cache && \
php artisan route:cache && \
chmod 777 -R /var/www/html/storage/ && \
chown -R www-data:www-data /var/www/ && \
a2enmod rewrite
9 changes: 6 additions & 3 deletions app/Console/Kernel.php
Expand Up @@ -23,7 +23,8 @@ protected function schedule(Schedule $schedule)
->runInBackground()
->after(function () {
mission_control_notify('Emptied the Failed Jobs table', 'maintenance');
});
})
->onOneServer();

$schedule->command('maintenance:gzip-purge')->monthlyOn(4, '4:45')
->runInBackground()
Expand All @@ -35,14 +36,16 @@ protected function schedule(Schedule $schedule)
->monthlyOn(4, '4:45')
->after(function (Stringable $output) {
mission_control_notify('PHP Outdated Parsing', 'maintenance', $output);
});
})
->onOneServer();

$schedule->command('maintenance:js-outdated')
->monthlyOn(4, '4:45')
->runInBackground()
->after(function (Stringable $output) {
mission_control_notify('JS Outdated Parsing', 'maintenance', $output);
});
})
->onOneServer();
}

/**
Expand Down
10 changes: 5 additions & 5 deletions app/Http/Controllers/Api/ApiController.php
Expand Up @@ -6,14 +6,14 @@

class ApiController extends Controller
{
public $user;

public function __construct()
public function user()
{
$this->user = auth('sanctum')->user();
$user = auth('sanctum')->user();

if (is_null($this->user) && ! app()->runningInConsole()) {
if (is_null($user) && ! app()->runningInConsole()) {
abort(401, 'Unauthorized.');
}

return $user;
}
}
8 changes: 8 additions & 0 deletions app/Http/Controllers/Api/ApiDeviceLoginController.php
Expand Up @@ -10,6 +10,14 @@

class ApiDeviceLoginController extends Controller
{
/**
* Device Login
*
* Create a new device token for the user.
* Otherwise we fall back to sanctum's default auth methodology.
*
* @return \Illuminate\Http\JsonResponse
*/
public function create(Request $request)
{
$request->validate([
Expand Down
16 changes: 8 additions & 8 deletions app/Http/Controllers/Api/UsersController.php
Expand Up @@ -18,7 +18,7 @@ class UsersController extends ApiController
public function me()
{
return response()->json([
'data' => new UserResource($this->user),
'data' => new UserResource($this->user()),
]);
}

Expand All @@ -30,13 +30,13 @@ public function me()
public function update(ApiUserUpdateRequest $request)
{
if (
$this->user->update([
$this->user()->update([
'email' => $request->json('email'),
'name' => $request->json('name'),
])
) {
return response()->json([
'data' => new UserResource($this->user),
'data' => new UserResource($this->user()),
'status' => 'Profile updated',
]);
}
Expand All @@ -53,17 +53,17 @@ public function update(ApiUserUpdateRequest $request)
*/
public function destroy()
{
if ($this->user->avatar) {
Storage::delete($this->user->avatar);
if ($this->user()->avatar) {
Storage::delete($this->user()->avatar);
}

$subject = 'Account Deletion.';
$message = 'Your account has been deleted.';

Notification::route('mail', $this->user->email)
->notify(new StandardEmail($this->user->name, $subject, $message));
Notification::route('mail', $this->user()->email)
->notify(new StandardEmail($this->user()->name, $subject, $message));

$this->user->delete();
$this->user()->delete();

return response()->json([
'status' => 'Profile deleted',
Expand Down
2 changes: 1 addition & 1 deletion app/Models/User.php
Expand Up @@ -2,7 +2,6 @@

namespace App\Models;

use App\Http\Forms\UserForm;
use App\Models\Concerns\DatabaseSearchable;
use App\Models\Concerns\HasActivity;
use App\Models\Concerns\HasAvatar;
Expand All @@ -14,6 +13,7 @@
use App\Models\Concerns\HasTeams;
use App\Models\Concerns\HasTwoFactor;
use App\Notifications\ResetPassword;
use App\View\Forms\UserForm;
use Grafite\Forms\Traits\HasForm;
use Grafite\Support\Models\Concerns\CanAccessFeatures;
use Grafite\Support\Models\Concerns\HasJavascriptData;
Expand Down
11 changes: 11 additions & 0 deletions app/Providers/AppServiceProvider.php
Expand Up @@ -3,10 +3,13 @@
namespace App\Providers;

use App\Models\User;
use Dedoc\Scramble\Scramble;
use Illuminate\Pagination\Paginator;
use Illuminate\Routing\Route;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
use Illuminate\Validation\Rules\Password;
use Laravel\Cashier\Cashier;

Expand Down Expand Up @@ -40,6 +43,14 @@ public function boot()
{
Paginator::useBootstrap();

Scramble::routes(function (Route $route) {
return Str::startsWith($route->uri, 'api/');
});

// Gate::define('viewApiDocs', function (User $user) {
// return in_array($user->email, ['admin@app.com']);
// });

Blade::if('permission', function ($value) {
return request()->user()->hasPermission($value);
});
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/AuthServiceProvider.php
Expand Up @@ -77,7 +77,7 @@ public function boot()

// Gateway for determining subscribers
Gate::define('subscribed', function ($user) {
return $user->hasActiveSubscription() || $user->onTrial();
return $user->hasActiveSubscription() || $user->onTrial() || $user->hasRole('admin');
});

// Gateway for determining not cancelled subscribers
Expand Down
2 changes: 1 addition & 1 deletion app/Services/ActivityService.php
Expand Up @@ -17,7 +17,7 @@ public function __construct(Activity $model)
* Create an activity record.
*
* @param string $description
* @return \App\Models\Activity
* @return \App\Models\Activity
*/
public function log($description = '')
{
Expand Down
4 changes: 0 additions & 4 deletions app/View/Forms/AdminUserForm.php
Expand Up @@ -6,7 +6,6 @@
use App\Models\User;
use Grafite\Forms\Fields\Bootstrap\HasOne;
use Grafite\Forms\Fields\Email;
use Grafite\Forms\Fields\Hidden;
use Grafite\Forms\Fields\Text;
use Grafite\Forms\Forms\ModelForm;

Expand Down Expand Up @@ -55,9 +54,6 @@ public function fields()
'sortable' => true,
'table_class' => 'd-none d-sm-table-cell',
]),
Hidden::make('role', [
'table_class' => 'd-none d-sm-table-cell',
]),
HasOne::make('role', [
'required' => true,
'visible' => false,
Expand Down
30 changes: 1 addition & 29 deletions app/View/Forms/UserForm.php
Expand Up @@ -3,14 +3,11 @@
namespace App\View\Forms;

use App\Models\User;
use Grafite\Forms\Fields\Country;
use Grafite\Forms\Fields\Email;
use Grafite\Forms\Fields\FileWithPreview;
use Grafite\Forms\Fields\Text;
use Grafite\Forms\Fields\Toggled;
use Grafite\Forms\Forms\ModelForm;
use Grafite\Forms\Html\Heading;
use Grafite\Forms\Html\HrTag;

class UserForm extends ModelForm
{
Expand All @@ -37,7 +34,7 @@ class UserForm extends ModelForm

public function fields()
{
return array_merge([
return [
Text::make('name', [
'required' => true,
]),
Expand All @@ -52,31 +49,6 @@ public function fields()
'preview_identifier' => '.avatar',
'preview_as_background_image' => true,
]),
]);
}

public function billingColumns()
{
return [
Heading::make([
'class' => 'mt-4 mb-1',
'content' => 'Billing Details',
'level' => 4,
]),
HrTag::make(),
Email::make('billing_email', [
'label' => 'Email',
'required' => auth()->user()->hasActiveSubscription(),
]),
Text::make('state', [
'label' => 'State',
'required' => auth()->user()->hasActiveSubscription(),
]),
Country::make('country', [
'label' => 'Country',
'required' => auth()->user()->hasActiveSubscription(),
'data-size' => 5,
]),
];
}
}

0 comments on commit 53b896a

Please sign in to comment.