Skip to content

Commit 981b903

Browse files
authored
Merge pull request #3514 from codeeu/dev
Dev
2 parents d32c852 + 1438554 commit 981b903

19 files changed

Lines changed: 931 additions & 44 deletions

app/CsrCampaignPage.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class CsrCampaignPage extends Model
8+
{
9+
protected $table = 'csr_campaign_page';
10+
11+
protected $fillable = [
12+
'use_dynamic_content',
13+
'hero_text',
14+
'primary_cta_text',
15+
'primary_cta_link',
16+
'secondary_cta_text',
17+
'secondary_cta_link',
18+
'about_title',
19+
'about_description',
20+
'resources_title',
21+
];
22+
23+
protected $casts = [
24+
'use_dynamic_content' => 'boolean',
25+
];
26+
27+
public function resources()
28+
{
29+
return $this->hasMany(CsrCampaignResource::class, 'page_id')->orderBy('position');
30+
}
31+
32+
public static function config(): self
33+
{
34+
$page = self::first();
35+
if ($page) {
36+
return $page;
37+
}
38+
39+
return self::create([
40+
'use_dynamic_content' => false,
41+
'primary_cta_link' => 'https://codeweek.eu/blog/futurereadycsr-campaign-launch',
42+
'secondary_cta_link' => 'https://codeweek.eu/blog/futurereadycsr-resources',
43+
]);
44+
}
45+
}

app/CsrCampaignResource.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class CsrCampaignResource extends Model
8+
{
9+
protected $table = 'csr_campaign_resources';
10+
11+
protected $fillable = [
12+
'page_id',
13+
'title',
14+
'description',
15+
'button_text',
16+
'button_link',
17+
'image',
18+
'image_mobile',
19+
'position',
20+
'active',
21+
];
22+
23+
protected $casts = [
24+
'position' => 'integer',
25+
'active' => 'boolean',
26+
];
27+
}

app/DancePage.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class DancePage extends Model
8+
{
9+
protected $table = 'dance_page';
10+
11+
protected $fillable = [
12+
'use_dynamic_content',
13+
'hero_title',
14+
'hero_subtitle',
15+
'content_intro_title',
16+
'content_intro_subtitle',
17+
'get_involved_title',
18+
'get_involved_subtitle',
19+
];
20+
21+
protected $casts = [
22+
'use_dynamic_content' => 'boolean',
23+
];
24+
25+
public static function config(): self
26+
{
27+
$page = self::first();
28+
if ($page) {
29+
return $page;
30+
}
31+
32+
return self::create([
33+
'use_dynamic_content' => false,
34+
]);
35+
}
36+
}

app/Http/Controllers/OnlineCoursesController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace App\Http\Controllers;
44

5+
use App\OnlineCoursesPage;
56
use App\OnlineCourse;
7+
use Illuminate\Support\Facades\Schema;
68
use Illuminate\View\View;
79

810
class OnlineCoursesController extends Controller
@@ -14,7 +16,8 @@ class OnlineCoursesController extends Controller
1416
public function index(): View
1517
{
1618
$onlineCourses = OnlineCourse::active()->ordered()->get();
19+
$page = Schema::hasTable('online_courses_page') ? OnlineCoursesPage::config() : null;
1720

18-
return view('online-courses', compact('onlineCourses'));
21+
return view('online-courses', compact('onlineCourses', 'page'));
1922
}
2023
}

app/Nova/CsrCampaignPage.php

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
namespace App\Nova;
4+
5+
use Illuminate\Http\Request;
6+
use Laravel\Nova\Fields\Boolean;
7+
use Laravel\Nova\Fields\HasMany;
8+
use Laravel\Nova\Fields\ID;
9+
use Laravel\Nova\Fields\Text;
10+
use Laravel\Nova\Fields\Trix;
11+
use Laravel\Nova\Http\Requests\NovaRequest;
12+
use Laravel\Nova\Panel;
13+
14+
class CsrCampaignPage extends Resource
15+
{
16+
public static $group = 'Content';
17+
public static $model = \App\CsrCampaignPage::class;
18+
public static $title = 'id';
19+
20+
public static function label()
21+
{
22+
return 'Future Ready CSR';
23+
}
24+
25+
public static function singularLabel()
26+
{
27+
return 'Future Ready CSR Page';
28+
}
29+
30+
public static function uriKey(): string
31+
{
32+
return 'csr-campaign-page';
33+
}
34+
35+
public static function indexQuery(NovaRequest $request, $query)
36+
{
37+
return $query->where('id', 1);
38+
}
39+
40+
public static function authorizedToCreate(Request $request): bool
41+
{
42+
return false;
43+
}
44+
45+
public function fields(Request $request): array
46+
{
47+
return [
48+
ID::make()->onlyOnForms(),
49+
Panel::make('General', [
50+
Boolean::make('Use dynamic content for this page', 'use_dynamic_content'),
51+
])->collapsable()->collapsedByDefault(),
52+
Panel::make('Hero', [
53+
Trix::make('Hero text', 'hero_text')->nullable(),
54+
Text::make('Primary CTA text', 'primary_cta_text')->nullable(),
55+
Text::make('Primary CTA link', 'primary_cta_link')->nullable(),
56+
Text::make('Secondary CTA text', 'secondary_cta_text')->nullable(),
57+
Text::make('Secondary CTA link', 'secondary_cta_link')->nullable(),
58+
])->collapsable()->collapsedByDefault(),
59+
Panel::make('About section', [
60+
Text::make('Title', 'about_title')->nullable(),
61+
Trix::make('Description', 'about_description')->nullable(),
62+
])->collapsable()->collapsedByDefault(),
63+
Panel::make('Resources section', [
64+
Text::make('Section title', 'resources_title')->nullable(),
65+
HasMany::make('Resources', 'resources', CsrCampaignResource::class),
66+
])->collapsable()->collapsedByDefault(),
67+
];
68+
}
69+
}

app/Nova/CsrCampaignResource.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace App\Nova;
4+
5+
use Illuminate\Http\Request;
6+
use Laravel\Nova\Fields\Boolean;
7+
use Laravel\Nova\Fields\ID;
8+
use Laravel\Nova\Fields\Number;
9+
use Laravel\Nova\Fields\Text;
10+
use Laravel\Nova\Fields\Textarea;
11+
use Laravel\Nova\Http\Requests\NovaRequest;
12+
13+
class CsrCampaignResource extends Resource
14+
{
15+
public static $model = \App\CsrCampaignResource::class;
16+
public static $title = 'title';
17+
public static $displayInNavigation = false;
18+
19+
public function fields(Request $request): array
20+
{
21+
return [
22+
ID::make()->sortable(),
23+
Text::make('Title', 'title')->nullable(),
24+
Textarea::make('Description', 'description')->nullable()->alwaysShow(),
25+
Text::make('Button text', 'button_text')->nullable(),
26+
Text::make('Button link', 'button_link')->nullable(),
27+
Text::make('Desktop image', 'image')->nullable(),
28+
Text::make('Mobile image', 'image_mobile')->nullable(),
29+
Number::make('Position', 'position')->min(0)->nullable(),
30+
Boolean::make('Active', 'active'),
31+
];
32+
}
33+
34+
public static function indexQuery(NovaRequest $request, $query)
35+
{
36+
return $query->orderBy('position')->orderBy('id');
37+
}
38+
}

app/Nova/DancePage.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
namespace App\Nova;
4+
5+
use Illuminate\Http\Request;
6+
use Laravel\Nova\Fields\Boolean;
7+
use Laravel\Nova\Fields\ID;
8+
use Laravel\Nova\Fields\Text;
9+
use Laravel\Nova\Fields\Trix;
10+
use Laravel\Nova\Http\Requests\NovaRequest;
11+
use Laravel\Nova\Panel;
12+
13+
class DancePage extends Resource
14+
{
15+
public static $group = 'Content';
16+
public static $model = \App\DancePage::class;
17+
public static $title = 'id';
18+
19+
public static function label()
20+
{
21+
return 'Dance Page';
22+
}
23+
24+
public static function singularLabel()
25+
{
26+
return 'Dance Page';
27+
}
28+
29+
public static function uriKey(): string
30+
{
31+
return 'dance-page';
32+
}
33+
34+
public static function indexQuery(NovaRequest $request, $query)
35+
{
36+
return $query->where('id', 1);
37+
}
38+
39+
public static function authorizedToCreate(Request $request): bool
40+
{
41+
return false;
42+
}
43+
44+
public function fields(Request $request): array
45+
{
46+
return [
47+
ID::make()->onlyOnForms(),
48+
Panel::make('General', [
49+
Boolean::make('Use dynamic content for this page', 'use_dynamic_content'),
50+
])->collapsable()->collapsedByDefault(),
51+
Panel::make('Hero', [
52+
Text::make('Hero title', 'hero_title')->nullable(),
53+
Trix::make('Hero subtitle', 'hero_subtitle')->nullable(),
54+
])->collapsable()->collapsedByDefault(),
55+
Panel::make('Content intro', [
56+
Text::make('Title', 'content_intro_title')->nullable(),
57+
Trix::make('Subtitle', 'content_intro_subtitle')->nullable(),
58+
])->collapsable()->collapsedByDefault(),
59+
Panel::make('Get involved section', [
60+
Text::make('Title', 'get_involved_title')->nullable(),
61+
Trix::make('Subtitle', 'get_involved_subtitle')->nullable(),
62+
])->collapsable()->collapsedByDefault(),
63+
];
64+
}
65+
}

app/Nova/OnlineCoursesPage.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
namespace App\Nova;
4+
5+
use Illuminate\Http\Request;
6+
use Laravel\Nova\Fields\Boolean;
7+
use Laravel\Nova\Fields\ID;
8+
use Laravel\Nova\Fields\Text;
9+
use Laravel\Nova\Fields\Trix;
10+
use Laravel\Nova\Http\Requests\NovaRequest;
11+
use Laravel\Nova\Panel;
12+
13+
class OnlineCoursesPage extends Resource
14+
{
15+
public static $group = 'Content';
16+
public static $model = \App\OnlineCoursesPage::class;
17+
public static $title = 'id';
18+
19+
public static function label()
20+
{
21+
return 'Online Courses Page';
22+
}
23+
24+
public static function singularLabel()
25+
{
26+
return 'Online Courses Page';
27+
}
28+
29+
public static function uriKey(): string
30+
{
31+
return 'online-courses-page';
32+
}
33+
34+
public static function indexQuery(NovaRequest $request, $query)
35+
{
36+
return $query->where('id', 1);
37+
}
38+
39+
public static function authorizedToCreate(Request $request): bool
40+
{
41+
return false;
42+
}
43+
44+
public function fields(Request $request): array
45+
{
46+
return [
47+
ID::make()->onlyOnForms(),
48+
Panel::make('General', [
49+
Boolean::make('Use dynamic content for this page', 'use_dynamic_content'),
50+
])->collapsable()->collapsedByDefault(),
51+
Panel::make('Hero', [
52+
Text::make('Title', 'hero_title')->nullable(),
53+
Trix::make('Text', 'hero_text')->nullable(),
54+
Text::make('CTA text', 'hero_cta_text')->nullable(),
55+
Text::make('CTA link', 'hero_cta_link')->nullable(),
56+
])->collapsable()->collapsedByDefault(),
57+
Panel::make('Intro section', [
58+
Text::make('Title', 'intro_title')->nullable(),
59+
Trix::make('Paragraph 1', 'intro_text_1')->nullable(),
60+
Trix::make('Paragraph 2', 'intro_text_2')->nullable(),
61+
Trix::make('Paragraph 3', 'intro_text_3')->nullable(),
62+
])->collapsable()->collapsedByDefault(),
63+
];
64+
}
65+
}

0 commit comments

Comments
 (0)