Skip to content

Commit

Permalink
fix menu composer
Browse files Browse the repository at this point in the history
  • Loading branch information
osbre committed Mar 17, 2020
1 parent 080c4f7 commit 1773146
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 49 deletions.
15 changes: 8 additions & 7 deletions resources/views/container/systems/menu.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@extends('platform::dashboard')

@section('title',__('Menu'))
@section('description',$name)
@section('title', __('Menu'))
@section('description', __($availableMenus[$name]))
@section('controller','components--menu')
@section('controller-data',"
data-content-loader-url='$name'
Expand All @@ -18,13 +18,14 @@
aria-haspopup="true"
aria-expanded="false">
<i class="icon-globe m-r-xs"></i>
{{$locales[$currentLocale]['native']}}
{{ $locales[$currentLocale] }}
</a>
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
@foreach($locales as $code => $locale)
<a class="dropdown-item" href="?lang={{$code}}"
<a class="dropdown-item" href="?lang={{ $code }}"
data-turbolinks-action="replace">
{{$locale['native']}}</a>
{{ $locale }}
</a>
@endforeach
</div>
</li>
Expand Down Expand Up @@ -63,10 +64,10 @@ class="dropdown-item">{{ __($value) }}
@section('content')

<div class="wrapper">
<div class="dd" data-lang="{{$currentLocale}}" data-name="{{$name}}">
<div class="dd" data-lang="{{ $currentLocale }}" data-name="{{ $name }}">
<ol class="dd-list">
@include('press::partials.menu.item',[
'menu'=>$menu
'menu' => $menu
])
</ol>
</div>
Expand Down
20 changes: 8 additions & 12 deletions src/Http/Composers/SystemMenuComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Orchid\Platform\Dashboard;
use Orchid\Platform\ItemMenu;
use Orchid\Platform\Menu;
use Orchid\Press\Models\Comment;

class SystemMenuComposer
{
Expand All @@ -15,11 +16,6 @@ class SystemMenuComposer
*/
private $dashboard;

/**
* MenuComposer constructor.
*
* @param Dashboard $dashboard
*/
public function __construct(Dashboard $dashboard)
{
$this->dashboard = $dashboard;
Expand All @@ -28,41 +24,41 @@ public function __construct(Dashboard $dashboard)
/**
* Registering the main menu items.
*/
public function compose()
public function compose(): void
{
$this->dashboard->menu
->add(Menu::SYSTEMS,
ItemMenu::label(__('Content management'))
ItemMenu::label('Content management')
->slug('CMS')
->icon('icon-layers')
->permission('platform.systems')
->permission('platform.systems.index')

This comment has been minimized.

Copy link
@osbre

osbre Mar 17, 2020

Author Contributor

Previously, this menu didn't work, that's why

->sort(1000)
)
->add('CMS',
ItemMenu::label(__('Menu'))
ItemMenu::label('Menu')
->icon('icon-menu')
->route('platform.systems.menu.index')
->permission('platform.systems.menu')
->canSee(count(config('press.menu', [])) > 0)
->title(__('Editing of a custom menu (navigation) using drag & drop and localization support.'))
)
->add('CMS',
ItemMenu::label(__('Categories'))
ItemMenu::label('Categories')
->icon('icon-briefcase')
->route('platform.systems.category')
->permission('platform.systems.category')
->sort(1000)
->title(__('Sort entries into groups of posts on a given topic. This helps the user to find the necessary information on the site.'))
)
->add('CMS',
ItemMenu::label(__('Comments'))
ItemMenu::label('Comments')
->icon('icon-bubbles')
->route('platform.systems.comments')
->permission('platform.systems.comments')
->sort(1000)
->title(__("Comments allow your website's visitors to have a discussion with you and each other."))
->badge(function () {
return \Orchid\Press\Models\Comment::where('approved', 0)->count() ?: null;
return Comment::where('approved', 0)->count() ?: null;
})
);
}
Expand Down
9 changes: 8 additions & 1 deletion src/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@
use Orchid\Support\Facades\Dashboard;

/**
* Class Post.
* @property int $user_id
* @property string $type
* @property string $status
* @property array $content
* @property array $options
* @property string $slug
* @property string $publish_at
* @property string $created_at
*/
class Post extends Model
{
Expand Down
9 changes: 2 additions & 7 deletions tests/Console/ArtisanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,14 @@

class ArtisanTest extends TestConsoleCase
{
/**
* debug: php vendor/bin/phpunit --filter= ArtisanTest tests\\Feature\\ArtisanTest --debug.
*
* @var
*/
public function testArtisanOrchidEntityMany()
public function testArtisanOrchidEntityMany(): void
{
$this->artisan('orchid:entity-many', ['name' => $this->generateNameFromMethod()])
->expectsOutput('Behavior created successfully.')
->assertExitCode(0);
}

public function testArtisanOrchidEntitySingle()
public function testArtisanOrchidEntitySingle(): void
{
$this->artisan('orchid:entity-single', ['name' => $this->generateNameFromMethod()])
->expectsOutput('Behavior created successfully.')
Expand Down
25 changes: 4 additions & 21 deletions tests/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use DaveJamesMiller\Breadcrumbs\Facades\Breadcrumbs;
use Illuminate\Database\Eloquent\Factory;
use Illuminate\Foundation\Application;
use Illuminate\Support\Str;
use Orchid\Database\Seeds\OrchidDatabaseSeeder;
use Orchid\Platform\Models\User;
Expand All @@ -15,16 +16,8 @@
use Orchid\Support\Facades\Dashboard;
use Watson\Active\Active;

/**
* Trait Environment.
*/
trait Environment
{
/**
* Setup the test environment.
* Run test: php vendor/bin/phpunit --coverage-html ./logs/coverage ./tests
* Run 1 test: php vendor/bin/phpunit --filter= UserTest tests\\Unit\\Platform\\UserTest --debug.
*/
protected function setUp(): void
{
parent::setUp();
Expand Down Expand Up @@ -52,7 +45,7 @@ protected function setUp(): void
}

/**
* @param \Illuminate\Foundation\Application $app
* @param Application $app
*/
protected function getEnvironmentSetUp($app)
{
Expand Down Expand Up @@ -111,25 +104,15 @@ protected function getEnvironmentSetUp($app)
]);
}

/**
* @param \Illuminate\Foundation\Application $app
*
* @return array
*/
protected function getPackageProviders($app)
protected function getPackageProviders(Application $app): array
{
return [
FoundationServiceProvider::class,
PressServiceProvider::class,
];
}

/**
* @param \Illuminate\Foundation\Application $app
*
* @return array
*/
protected function getPackageAliases($app)
protected function getPackageAliases(Application $app): array
{
return [
'Alert' => Alert::class,
Expand Down
2 changes: 1 addition & 1 deletion tests/TestConsoleCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ abstract class TestConsoleCase extends TestCase
*/
public function generateNameFromMethod(): string
{
return studly_case(debug_backtrace()[1]['function'].Str::random());
return Str::studly(debug_backtrace()[1]['function'].Str::random());
}
}

0 comments on commit 1773146

Please sign in to comment.