Skip to content

Commit

Permalink
Merge pull request #81 from digearthworks/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
inmanturbo authored Jun 5, 2021
2 parents b173e65 + 63fdda2 commit 462a0ae
Show file tree
Hide file tree
Showing 42 changed files with 569 additions and 118 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ supervisord.pid
.php_cs.cache
.phpstorm.meta.php
_ide_helper.php
.idea
.idea
Envoy*
!Envoy.blade.php
17 changes: 15 additions & 2 deletions Envoy.blade.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@

@servers(['localhost' => '127.0.0.1'])

@setup
define('LARAVEL_START', microtime(true));

$app = require_once __DIR__.'/bootstrap/app.php';

$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);

$kernel->bootstrap();
@endsetup

@task('dev', ['on'=> 'localhost'])
php artisan key:generate
yarn && yarn run dev
php artisan storage:link
php artisan passport:keys
php artisan db:wipe
php artisan migrate:refresh --seed
@if((config('template.cms.cms') && config('template.cms.driver') === 'wink'))
php artisan wink:install
php artisan wink:migrate
@endif
php artisan migrate --seed
{{ isset($test) ? 'php artisan test' : '' }}
@endtask

Expand All @@ -16,4 +30,3 @@
git pull {{ isset($remote) ? $remote : ''}} {{isset($branch) ? $branch : '' }}
composer update
@endtask

59 changes: 30 additions & 29 deletions app/Helpers/Global/SystemHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,38 +37,39 @@ function includeRouteFiles($folder)
}
}

if (!function_exists('adminer_object')) {
function adminer_object()
{
// required to run any plugin
// include_once base_path('/adminer/plugins/plugin.php');

function adminer_object()
{
// required to run any plugin
include_once base_path('/adminer/plugins/plugin.php');
// autoloader
foreach (glob(base_path('/adminer/plugins/*.php')) as $filename) {
include_once "$filename";
}

// autoloader
foreach (glob(base_path('/adminer/plugins/*.php')) as $filename) {
include_once "$filename";
}
$plugins = [
// specify enabled plugins here
// new AdminerDumpXml,
// new AdminerTinymce,
// new AdminerFileUpload("data/"),
// new AdminerSlugify,
// new AdminerTranslation,
// new AdminerForeignSystem,
// new AdminerDesigns;
new AdminerTablesFilter,
new AdminerFrames,
new AdminerDumpAlter,
new AdminerDumpJson,
new AdminerJsonColumn,
];

$plugins = [
// specify enabled plugins here
// new AdminerDumpXml,
// new AdminerTinymce,
// new AdminerFileUpload("data/"),
// new AdminerSlugify,
// new AdminerTranslation,
// new AdminerForeignSystem,
// new AdminerDesigns;
new AdminerTablesFilter,
new AdminerFrames,
new AdminerDumpAlter,
new AdminerDumpJson,
new AdminerJsonColumn,
];
/* It is possible to combine customization and plugins:
class AdminerCustomization extends AdminerPlugin {
}
return new AdminerCustomization($plugins);
*/

/* It is possible to combine customization and plugins:
class AdminerCustomization extends AdminerPlugin {
return new AdminerPlugin($plugins);
}
return new AdminerCustomization($plugins);
*/

return new AdminerPlugin($plugins);
}
104 changes: 104 additions & 0 deletions app/Http/Controllers/Bridge/WinkBridgeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php

namespace App\Http\Controllers\Bridge;

use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\ValidationException;
use Wink\WinkAuthor;

class WinkBridgeController extends Controller
{
/**
* Show the application's login form.
*
* @return \Illuminate\Http\Response
*/
public function showLoginForm()
{
if ($this->bridge()) {

$this->loginAppUserAsWinkAuthor(auth('web')->user());
return redirect()->intended('/' . config('wink.path'));
}
return view('wink::login');
}

/**
* Attempt to log in.
*
* @return \Illuminate\Http\Response
*/
public function login()
{
if ($this->bridge()) {

$this->loginAppUserAsWinkAuthor(auth('web')->user());
return redirect()->intended('/' . config('wink.path'));
}

validator(request()->all(), [
'email' => 'required|string',
'password' => 'required|string',
]);

if ($this->guard()->attempt(
request()->only('email', 'password'),
request()->filled('remember')
)) {
return redirect('/' . config('wink.path'));
}

throw ValidationException::withMessages([
'email' => ['Invalid email or password!'],
]);
}

/**
* Log the user out of the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function logout(Request $request)
{
$this->guard()->logout();

$request->session()->invalidate();

return redirect()->route('wink.auth.login')->with('loggedOut', true);
}

/**
* Get the guard to be used during authentication.
*
* @return \Illuminate\Contracts\Auth\StatefulGuard
*/
protected function guard()
{
return Auth::guard('wink');
}

protected function bridge(): bool
{
if (auth('web')->user() && $this->checkIfAppUserIsWinkAuthor(auth('web')->user())) {
return true;
}

return false;
}

protected function checkIfAppUserIsWinkAuthor(User $user): bool
{
return $user->isWinkAuthor();
}

protected function loginAppUserAsWinkAuthor(User $user)
{
return auth('wink')->login(
WinkAuthor::where('email', $user->email)->first()
);
}
}
4 changes: 2 additions & 2 deletions app/Http/Livewire/Admin/Menu/CreateMenuForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CreateMenuForm extends BaseCreateForm
public $state = [
'group' => 'app',
'name' => '',
'meta_name' => '',
'handle' => '',
'link' => '',
'type' => 'main_menu',
'active' => '1',
Expand Down Expand Up @@ -70,7 +70,7 @@ public function createMenu(MenuService $menus)
Validator::make($this->state, [
'group' => ['string', 'required'],
'name' => ['required', 'string'],
'meta_name' => ['required', 'string'],
'handle' => ['required', 'string'],
'type' => ['required', 'string'],
'active' => ['int'],
'title' => ['string'],
Expand Down
19 changes: 14 additions & 5 deletions app/Http/Livewire/Admin/Menu/EditMenuForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
use App\Models\Menu;
use App\Services\MenuService;
use App\Support\Concerns\InteractsWithBanner;
use Exception;
use Illuminate\Support\Facades\Validator;
use Log;

class EditMenuForm extends BaseEditForm
{
Expand All @@ -32,7 +34,7 @@ class EditMenuForm extends BaseEditForm
public $state = [
'group' => 'app',
'name' => '',
'meta_name' => '',
'handle' => '',
'link' => '',
'type' => 'main_menu',
'active' => '1',
Expand All @@ -57,7 +59,7 @@ public function editDialog($resourceId, $params = null)
$this->modelId = $resourceId;
$this->state['group'] = $this->model->group;
$this->state['name'] = $this->model->name;
$this->state['meta_name'] = $this->model->meta_name;
$this->state['handle'] = $this->model->handle;
$this->state['link'] = $this->model->link;
$this->state['type'] = $this->model->type;
$this->state['active'] = $this->model->active;
Expand All @@ -83,19 +85,26 @@ public function updateMenu(MenuService $menus)
{
$this->authorize('is_admin');

// dd($this->state);

$this->resetErrorBag();
Validator::make($this->state, [
'group' => ['string'],
'name' => ['required', 'string'],
'meta_name' => ['required', 'string'],
'handle' => ['required', 'string'],
'type' => ['required', 'string'],
'active' => ['int'],
'title' => ['string', 'nullable'],
'iframe' => ['int'],
'sort' => ['int', 'nullable'],
])->validateWithBag('editMenuForm');

$menus->update($this->state, $this->model);
try {
$menus->update($this->state, $this->model);
} catch (Exception $e) {
Log::error($e);
}

$this->emit('refreshWithSuccess', 'Menu Updated!');
$this->emit('refreshMenuGrid');
$this->banner('Menu Updated');
Expand All @@ -110,7 +119,7 @@ public function saveMenuAs(MenuService $menus)
Validator::make($this->state, [
'group' => ['string'],
'name' => ['required', 'string'],
'meta_name' => ['required', 'string'],
'handle' => ['required', 'string'],
'type' => ['required', 'string'],
'active' => ['int'],
'title' => ['string', 'nullable'],
Expand Down
Loading

0 comments on commit 462a0ae

Please sign in to comment.