Skip to content
This repository has been archived by the owner on Aug 5, 2021. It is now read-only.

Commit

Permalink
reworked the package so it does not require publishing all the assets…
Browse files Browse the repository at this point in the history
…; updated readme
  • Loading branch information
Jantho1990 committed May 9, 2018
1 parent c341016 commit 701759b
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 25 deletions.
4 changes: 2 additions & 2 deletions package/src/app/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(array $attributes = array())
parent::__construct($attributes);

// We need to set this here so we can use the config value.
$this->table = config('showcase.table_prefix').$this->table;
$this->table = config('showcase.table_prefix', 'showcase_').$this->table;
}

/**
Expand All @@ -31,7 +31,7 @@ public function __construct(array $attributes = array())
*/
public function trophies()
{
return $this->belongsToMany('Showcase\App\Trophy', config('showcase.table_prefix').'display_trophy');
return $this->belongsToMany('Showcase\App\Trophy', config('showcase.table_prefix', 'showcase_').'display_trophy');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion package/src/app/Http/Requests/DisplayRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function rules()
{
$name = $this->method() === 'PUT'
? 'required|string|max:255'
: 'required|string|unique:'.config('showcase.table_prefix').'displays,name|max:255';
: 'required|string|unique:'.config('showcase.table_prefix', 'showcase_').'displays,name|max:255';

return [
'name' => $name,
Expand Down
4 changes: 2 additions & 2 deletions package/src/app/Http/Requests/TrophyRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ public function rules()
{
$name = $this->method() === 'PUT'
? 'nullable|string|max:255'
: 'nullable|string|unique:'.config('showcase.table_prefix').'trophies,name|max:255';
: 'nullable|string|unique:'.config('showcase.table_prefix', 'showcase_').'trophies,name|max:255';

return [
'name' => $name,
'component_view' => 'string',
'link' => 'nullable|url',
'image_url' => 'nullable|url',
'description' => 'nullable|string|max:'.config('showcase.description_length')
'description' => 'nullable|string|max:'.config('showcase.description_length', 55)
];
}

Expand Down
6 changes: 5 additions & 1 deletion package/src/app/Providers/ShowcaseProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public function boot()
__DIR__.'/../../resources/views' => resource_path('/views/vendor/showcase'),
], 'showcase');

$this->publishes([
__DIR__.'/../../resources/assets/build' => public_path('vendor/showcase'),
], 'showcase-assets');

Blade::directive('showcaseDisplay', function ($display) {
return "<?php \$__env->startComponent(\"showcase::public.components.display.{$display}->component_view\", ['display' => {$display}]); ?><?php echo \$__env->renderComponent(); ?>";
});
Expand All @@ -43,7 +47,7 @@ public function boot()
return "<?php \$__env->startComponent(\"showcase::public.components.trophy.\".($showcaseStr), ['trophy' => {$trophy}, 'display' => $displayStr]); ?><?php echo \$__env->renderComponent(); ?>";
});

if (count(\DB::select(\DB::raw('SHOW TABLES LIKE "' . config('showcase.table_prefix').'displays"'))) > 0) {
if (count(\DB::select(\DB::raw('SHOW TABLES LIKE "' . config('showcase.table_prefix', 'showcase_').'displays"'))) > 0) {
$displays = \Showcase\App\Display::with('trophies')->get();
$trophies = \Showcase\App\Trophy::all();
View::share('displays', $displays);
Expand Down
4 changes: 2 additions & 2 deletions package/src/app/Trophy.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(array $attributes = array())
parent::__construct($attributes);

// We need to set this here so we can use the config value.
$this->table = config('showcase.table_prefix').$this->table;
$this->table = config('showcase.table_prefix', 'showcase_').$this->table;
}

/**
Expand All @@ -31,7 +31,7 @@ public function __construct(array $attributes = array())
*/
public function displays()
{
return $this->belongsToMany('Showcase\App\Display', config('showcase.table_prefix').'display_trophy');
return $this->belongsToMany('Showcase\App\Display', config('showcase.table_prefix', 'showcase_').'display_trophy');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CreateDisplaysTable extends Migration
*/
public function up()
{
Schema::create(config('showcase.table_prefix').'displays', function (Blueprint $table) {
Schema::create(config('showcase.table_prefix', 'showcase_').'displays', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('component_view');
Expand All @@ -30,6 +30,6 @@ public function up()
*/
public function down()
{
Schema::dropIfExists(config('showcase.table_prefix').'displays');
Schema::dropIfExists(config('showcase.table_prefix', 'showcase_').'displays');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CreateTrophiesTable extends Migration
*/
public function up()
{
Schema::create(config('showcase.table_prefix').'trophies', function (Blueprint $table) {
Schema::create(config('showcase.table_prefix', 'showcase_').'trophies', function (Blueprint $table) {
$table->increments('id');
$table->string('component_view');
$table->string('name')->nullable();
Expand All @@ -31,6 +31,6 @@ public function up()
*/
public function down()
{
Schema::dropIfExists(config('showcase.table_prefix').'trophies');
Schema::dropIfExists(config('showcase.table_prefix', 'showcase_').'trophies');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CreateDisplayTrophyTable extends Migration
*/
public function up()
{
Schema::create(config('showcase.table_prefix').'display_trophy', function (Blueprint $table) {
Schema::create(config('showcase.table_prefix', 'showcase_').'display_trophy', function (Blueprint $table) {
$table->increments('id');
$table->integer('display_id');
$table->integer('trophy_id');
Expand All @@ -27,6 +27,6 @@ public function up()
*/
public function down()
{
Schema::dropIfExists(config('showcase.table_prefix').'display_trophy');
Schema::dropIfExists(config('showcase.table_prefix', 'showcase_').'display_trophy');
}
}
6 changes: 3 additions & 3 deletions package/src/database/seeds/DisplayTrophyTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ public function run()
'name' => 'Sample Sheet',
'component_view' => 'display_sheet'
]); */
DB::table(config('showcase.table_prefix').'display_trophy')->insert([
DB::table(config('showcase.table_prefix', 'showcase_').'display_trophy')->insert([
'display_id' => 1,
'trophy_id' => 1
]);
DB::table(config('showcase.table_prefix').'display_trophy')->insert([
DB::table(config('showcase.table_prefix', 'showcase_').'display_trophy')->insert([
'display_id' => 1,
'trophy_id' => 2
]);
DB::table(config('showcase.table_prefix').'display_trophy')->insert([
DB::table(config('showcase.table_prefix', 'showcase_').'display_trophy')->insert([
'display_id' => 2,
'trophy_id' => 3
]);
Expand Down
4 changes: 2 additions & 2 deletions package/src/database/seeds/DisplaysTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ public function run()
'name' => 'Sample Sheet',
'component_view' => 'display_sheet'
]); */
DB::table(config('showcase.table_prefix').'displays')->insert([
DB::table(config('showcase.table_prefix', 'showcase_').'displays')->insert([
'name' => 'Sample Box',
'component_view' => 'box',
'default_trophy_component_view' => 'default',
'force_trophy_default' => false,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
]);
DB::table(config('showcase.table_prefix').'displays')->insert([
DB::table(config('showcase.table_prefix', 'showcase_').'displays')->insert([
'name' => 'Sample Sheet',
'component_view' => 'sheet',
'default_trophy_component_view' => 'description',
Expand Down
6 changes: 3 additions & 3 deletions package/src/database/seeds/TrophiesTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function run()
'description' => 'A boring item which links somewhere.',
'display_id' => 2
]); */
DB::table(config('showcase.table_prefix').'trophies')->insert([
DB::table(config('showcase.table_prefix', 'showcase_').'trophies')->insert([
'component_view' => 'default',
'name' => 'Sample Box Item 1',
'link' => 'http://google.com',
Expand All @@ -37,7 +37,7 @@ public function run()
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
]);
DB::table(config('showcase.table_prefix').'trophies')->insert([
DB::table(config('showcase.table_prefix', 'showcase_').'trophies')->insert([
'component_view' => 'no_title',
'name' => 'Sample Box Item 2',
'link' => 'http://google.com',
Expand All @@ -46,7 +46,7 @@ public function run()
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
]);
DB::table(config('showcase.table_prefix').'trophies')->insert([
DB::table(config('showcase.table_prefix', 'showcase_').'trophies')->insert([
'component_view' => 'description',
'name' => 'Sample Sheet Item',
'link' => 'http://google.com',
Expand Down
2 changes: 1 addition & 1 deletion package/src/routes.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

Route::middleware(config('showcase.middleware'))->group(function () {
Route::middleware(config('showcase.middleware', ['web', 'auth']))->group(function () {
Route::resource('displays', 'Showcase\App\Http\Controllers\DisplayController');
Route::resource('trophies', 'Showcase\App\Http\Controllers\TrophyController');
});
10 changes: 9 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,18 @@ A Laravel package which adds the ability to create "showcases", or view boxes wh
```
composer require brokerexchange/showcase
```

To include the assets, you have two options:
1. `@import "vendor/brokerexchange/showcase/resources/assets/build/public";` in your main stylesheet, which will include the styles as part of your app's compiled styles.
2. `php artisan vendor:publish --tag=showcase-assets` and link to `/vendor/showcase/public.css` in the `<head>`.

If you want to publish all the assets:
```
php artisan vendor:publish --tag=showcase
```

You will need to add a link to `/vendor/showcase/public.css` to your project's `head` section, wherever the rest of your stylesheets are being included. Alteratively, if you'd rather bundle the public styles to your app stylesheet, you can import them by add `@import "public/vendor/showcase/public";` to your main stylesheet.
> TODO: Finish this section and fix things so you don't have to use public/vendor
### Install the package development environment

Expand Down
2 changes: 1 addition & 1 deletion update-test-project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ composer update brokerexchange/showcase
composer dump-autoload
php artisan cache:clear
php artisan view:clear
php artisan vendor:publish --tag=showcase --force
php artisan vendor:publish --tag=showcase-assets --force
if [ "$migrations" = true ]; then
php artisan migrate:refresh --seed
php artisan db:seed --class=ShowcaseDatabaseSeeder
Expand Down

0 comments on commit 701759b

Please sign in to comment.