increments('category_id'); $table->unsignedInteger('parent_id')->default(0); $table->unsignedTinyInteger('active')->default(1); $table->integer('num')->default(0); }); Schema::create('projects_categories_description', function (Blueprint $table) { $table->id(); $table->unsignedInteger('category_id'); $table->char('iso', 3); $table->string('title'); }); Schema::create('projects', function (Blueprint $table) { $table->increments('project_id'); $table->unsignedInteger('category_id')->nullable()->default(0); $table->unsignedTinyInteger('active')->default(1); $table->string('picture_cover')->nullable(); $table->string('picture_catalog')->nullable(); $table->string('picture_catalog_full')->nullable(); $table->string('video')->nullable(); $table->json('categories')->nullable(); $table->text('structure')->nullable(); $table->string('bgColor')->nullable(); $table->timestamps(); }); Schema::create('projects_description', function (Blueprint $table) { $table->id(); $table->unsignedInteger('project_id'); $table->char('iso', 3); $table->string('headline'); $table->string('subline')->nullable(); $table->string('name')->nullable(); $table->integer('year')->nullable(); $table->text('preview')->nullable(); $table->longText('content')->nullable(); $table->string('tag1')->nullable(); $table->string('tag2')->nullable(); $table->string('tag3')->nullable(); $table->string('youtube')->nullable(); $table->string('page_title')->nullable(); $table->string('meta_title')->nullable(); $table->string('meta_description')->nullable(); $table->string('og_title')->nullable(); $table->string('og_description')->nullable(); }); Schema::create('projects_gallery', function (Blueprint $table) { $table->increments('photo_id'); $table->unsignedInteger('project_id'); $table->integer('num')->default(0); $table->string('diskname'); $table->string('name')->nullable(); }); Schema::create('blocks', function (Blueprint $table) { $table->increments('block_id'); $table->string('keycode', 64)->unique(); $table->json('attributes')->nullable(); $table->string('notes')->nullable(); $table->boolean('active')->default(true); $table->string('block_group', 16)->nullable(); $table->softDeletes(); $table->timestamps(); }); DB::table('blocks')->insert([ [ 'keycode' => 'WORK-HEADER', 'attributes' => json_encode(['sl' => ['content' => '']]), 'active' => true, 'created_at' => now(), 'updated_at' => now(), ], [ 'keycode' => 'FOOTER-BLOCK', 'attributes' => json_encode(['sl' => ['content' => '']]), 'active' => true, 'created_at' => now(), 'updated_at' => now(), ], [ 'keycode' => 'FOOTER-HOME-BLOCK', 'attributes' => json_encode(['sl' => ['content' => '']]), 'active' => true, 'created_at' => now(), 'updated_at' => now(), ], ]); }); function seedPublicProject(int $id, string $headline, int $categoryId, ?array $structure = null): void { DB::table('projects')->insert([ 'project_id' => $id, 'category_id' => $categoryId, 'active' => 1, 'categories' => json_encode([$categoryId]), 'structure' => $structure ? json_encode($structure) : null, 'created_at' => now(), 'updated_at' => now(), ]); DB::table('projects_description')->insert([ 'project_id' => $id, 'iso' => 'sl', 'headline' => $headline, 'name' => 'Client ' . $id, 'preview' => 'Preview ' . $id, 'content' => 'Content ' . $id, 'tag1' => 'Award ' . $id, 'youtube' => 'https://www.youtube.com/watch?v=ScMzIvxBSi4', ]); } it('renders public work cards from projects records', function () { DB::table('projects_categories')->insert([ 'category_id' => 1, 'parent_id' => 0, 'active' => 1, 'num' => 1, ]); DB::table('projects_categories_description')->insert([ 'category_id' => 1, 'iso' => 'sl', 'title' => 'Branding', ]); seedPublicProject(10, 'Golden Drum', 1); get('/sl/work') ->assertSuccessful() ->assertSee('Golden Drum', false) ->assertSee('/sl/project/10/golden-drum', false) ->assertSee('Branding', false); }); it('renders bunny video thumbnails on the work page when configured in project settings', function () { DB::table('projects_categories')->insert([ 'category_id' => 1, 'parent_id' => 0, 'active' => 1, 'num' => 1, ]); DB::table('projects_categories_description')->insert([ 'category_id' => 1, 'iso' => 'sl', 'title' => 'Branding', ]); seedPublicProject(18, 'Video Thumb Project', 1, [ 'header' => ['headline' => 'Video Thumb Project'], 'thumbnailMedia' => [ 'type' => 'bunny', 'url' => 'https://player.mediadelivery.net/embed/12345/abcde', 'autoplay' => true, 'loop' => true, 'muted' => true, ], 'heroMedia' => ['type' => 'image', 'url' => ''], 'metadata' => ['clientName' => 'Client 18', 'awarded' => [], 'description' => 'Preview 18'], 'contentBlocks' => [], ]); get('/sl/work') ->assertSuccessful() ->assertSee('Video Thumb Project', false) ->assertSee('player.mediadelivery.net/embed/12345/abcde', false) ->assertSee('autoplay=true', false) ->assertSee('loop=true', false) ->assertSee('muted=true', false); }); it('falls back to the bunny hero video on the work page when the thumbnail is set to bunny without its own url', function () { DB::table('projects_categories')->insert([ 'category_id' => 1, 'parent_id' => 0, 'active' => 1, 'num' => 1, ]); DB::table('projects_categories_description')->insert([ 'category_id' => 1, 'iso' => 'sl', 'title' => 'Branding', ]); seedPublicProject(18, 'Haloško srce', 1, [ 'header' => ['headline' => 'Haloško srce'], 'thumbnailMedia' => [ 'type' => 'bunny', 'url' => '', 'autoplay' => true, 'loop' => true, 'muted' => true, ], 'heroMedia' => [ 'type' => 'bunny', 'url' => 'https://player.mediadelivery.net/embed/98765/hero-video', 'autoplay' => true, 'loop' => true, 'muted' => true, ], 'metadata' => ['clientName' => 'Client 18', 'awarded' => [], 'description' => 'Preview 18'], 'contentBlocks' => [], ]); get('/sl/work') ->assertSuccessful() ->assertSee('Haloško srce', false) ->assertSee('player.mediadelivery.net/embed/98765/hero-video', false) ->assertSee('autoplay=true', false) ->assertSee('loop=true', false) ->assertSee('muted=true', false); }); it('renders the selected project and the next project navigation', function () { DB::table('projects_categories')->insert([ ['category_id' => 1, 'parent_id' => 0, 'active' => 1, 'num' => 1], ['category_id' => 2, 'parent_id' => 0, 'active' => 1, 'num' => 2], ]); DB::table('projects_categories_description')->insert([ ['category_id' => 1, 'iso' => 'sl', 'title' => 'Branding'], ['category_id' => 2, 'iso' => 'sl', 'title' => 'Campaign'], ]); seedPublicProject(11, 'First Project', 1, [ 'header' => ['headline' => 'First Project'], 'heroMedia' => ['type' => 'youtube', 'url' => 'https://www.youtube.com/watch?v=ScMzIvxBSi4'], 'metadata' => ['clientName' => 'SOZ', 'awarded' => ['Award 1'], 'description' => 'Desc'], 'contentBlocks' => [], ]); seedPublicProject(9, 'Second Project', 2); get('/sl/project/11/first-project') ->assertSuccessful() ->assertSee('First Project', false) ->assertSee('/sl/project/9/second-project', false) ->assertSee('Next project', false); }); it('prefers the translated project description over the schema sample', function () { DB::table('projects_categories')->insert([ 'category_id' => 1, 'parent_id' => 0, 'active' => 1, 'num' => 1, ]); DB::table('projects_categories_description')->insert([ 'category_id' => 1, 'iso' => 'sl', 'title' => 'Branding', ]); seedPublicProject(12, 'Project Twelve', 1, [ 'header' => ['headline' => ''], 'heroMedia' => ['type' => 'image', 'url' => ''], 'metadata' => ['clientName' => 'SOZ', 'awarded' => [], 'description' => 'A modular project schema that can drive both the public page and the cPad editor preview.'], 'contentBlocks' => [], ]); DB::table('projects_description')->where('project_id', 12)->update([ 'preview' => 'Ne za kogarkoli, ampak za Golden Drum. Festival, ki vstopa v četrto desetletje in še vedno premika meje.', ]); get('/sl/project/12/project-twelve') ->assertSuccessful() ->assertSee('Ne za kogarkoli, ampak za Golden Drum. Festival, ki vstopa v četrto desetletje in še vedno premika meje.', false) ->assertDontSee('A modular project schema that can drive both the public page and the cPad editor preview.', false); });