Skip to content

Commit ca93e89

Browse files
authored
Merge pull request #25 from codebar-ag/main
main/production
2 parents bc3abb5 + ced8552 commit ca93e89

19 files changed

Lines changed: 473 additions & 18 deletions

app/Actions/ViewDataAction.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
use App\Models\Configuration;
88
use App\Models\Contact;
99
use App\Models\News;
10+
use App\Models\OpenSource;
1011
use App\Models\Product;
1112
use App\Models\Service;
13+
use App\Models\Technology;
1214
use Illuminate\Support\Collection;
1315
use Illuminate\Support\Facades\Cache;
1416
use Illuminate\Support\Str;
@@ -51,6 +53,24 @@ public function news(string $locale): Collection
5153
});
5254
}
5355

56+
public function technologies(string $locale): Collection
57+
{
58+
$key = Str::slug("technologies_published_{$locale}");
59+
60+
return Cache::rememberForever($key, function () use ($locale) {
61+
return Technology::where('locale', $locale)->where('published', true)->orderBy('order')->get();
62+
});
63+
}
64+
65+
public function openSource(string $locale): Collection
66+
{
67+
$key = Str::slug("open_source_published_{$locale}");
68+
69+
return Cache::rememberForever($key, function () use ($locale) {
70+
return OpenSource::where('locale', $locale)->where('published', true)->orderByDesc('downloads')->get();
71+
});
72+
}
73+
5474
public function contacts(string $locale): object
5575
{
5676
$key = Str::slug("contacts_published_{$locale}");

app/Http/Controllers/OpenSource/OpenSoruceShowController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class OpenSoruceShowController extends Controller
1515
*/
1616
public function __invoke(string $locale, Product $product): View
1717
{
18-
return view('app.products.show')->with([
18+
return view('app.open-source.show')->with([
1919
'page' => (new PageAction(locale: $locale))->product(product: $product),
2020
'name' => $product->name,
2121
'teaser' => $product->teaser,

app/Http/Controllers/OpenSource/OpenSourceIndexController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public function __invoke(): View
1616
{
1717
$locale = app()->getLocale();
1818

19-
return view('app.products.index')->with([
20-
'page' => (new PageAction(locale: null, routeName: 'products.index'))->default(),
21-
'products' => (new ViewDataAction)->products($locale),
19+
return view('app.open-source.index')->with([
20+
'page' => (new PageAction(locale: null, routeName: 'open-source.index'))->default(),
21+
'openSource' => (new ViewDataAction)->openSource($locale),
2222
]);
2323
}
2424
}

app/Http/Controllers/Technologies/TechnologiesIndexController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public function __invoke(): View
1616
{
1717
$locale = app()->getLocale();
1818

19-
return view('app.products.index')->with([
20-
'page' => (new PageAction(locale: null, routeName: 'products.index'))->default(),
21-
'products' => (new ViewDataAction)->products($locale),
19+
return view('app.technologies.index')->with([
20+
'page' => (new PageAction(locale: null, routeName: 'technologies.index'))->default(),
21+
'technologies' => (new ViewDataAction)->technologies($locale),
2222
]);
2323
}
2424
}

app/Models/OpenSource.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace App\Models;
4+
5+
use App\Enums\LocaleEnum;
6+
use App\Traits\HasLocalizedReferences;
7+
use App\Traits\HasLocalizedRouteBinding;
8+
use Illuminate\Database\Eloquent\Factories\HasFactory;
9+
use Illuminate\Database\Eloquent\Model;
10+
11+
class OpenSource extends Model
12+
{
13+
use HasFactory;
14+
use HasLocalizedReferences;
15+
use HasLocalizedRouteBinding;
16+
17+
protected $casts = [
18+
'published' => 'boolean',
19+
'locale' => LocaleEnum::class,
20+
'tags' => 'json',
21+
'downloads' => 'int',
22+
];
23+
24+
public function getRouteKeyName(): string
25+
{
26+
return 'slug';
27+
}
28+
}

app/Models/Technology.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\Models;
4+
5+
use App\Enums\LocaleEnum;
6+
use App\Traits\HasLocalizedReferences;
7+
use App\Traits\HasLocalizedRouteBinding;
8+
use Illuminate\Database\Eloquent\Factories\HasFactory;
9+
use Illuminate\Database\Eloquent\Model;
10+
11+
class Technology extends Model
12+
{
13+
use HasFactory;
14+
use HasLocalizedReferences;
15+
use HasLocalizedRouteBinding;
16+
17+
protected $casts = [
18+
'published' => 'boolean',
19+
'locale' => LocaleEnum::class,
20+
'tags' => 'json',
21+
];
22+
23+
public function getRouteKeyName(): string
24+
{
25+
return 'slug';
26+
}
27+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Database\Factories;
4+
5+
use Illuminate\Database\Eloquent\Factories\Factory;
6+
7+
/**
8+
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\OpenSource>
9+
*/
10+
class OpenSourceFactory extends Factory
11+
{
12+
/**
13+
* Define the model's default state.
14+
*
15+
* @return array<string, mixed>
16+
*/
17+
public function definition(): array
18+
{
19+
return [
20+
//
21+
];
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Database\Factories;
4+
5+
use Illuminate\Database\Eloquent\Factories\Factory;
6+
7+
/**
8+
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Technology>
9+
*/
10+
class TechnologyFactory extends Factory
11+
{
12+
/**
13+
* Define the model's default state.
14+
*
15+
* @return array<string, mixed>
16+
*/
17+
public function definition(): array
18+
{
19+
return [
20+
//
21+
];
22+
}
23+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('open_sources', function (Blueprint $table) {
15+
$table->id();
16+
$table->boolean('published')->default(false);
17+
$table->string('locale');
18+
$table->string('title');
19+
$table->string('slug');
20+
$table->string('teaser');
21+
$table->longText('content')->nullable();
22+
$table->string('image');
23+
$table->json('tags')->nullable();
24+
$table->string('link')->nullable();
25+
$table->integer('downloads')->nullable();
26+
$table->string('version')->nullable();
27+
$table->timestamps();
28+
29+
$table->unique(['slug', 'locale']);
30+
});
31+
}
32+
33+
/**
34+
* Reverse the migrations.
35+
*/
36+
public function down(): void
37+
{
38+
Schema::dropIfExists('open_sources');
39+
}
40+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('technologies', function (Blueprint $table) {
15+
$table->id();
16+
$table->boolean('published')->default(false);
17+
$table->string('locale');
18+
$table->string('group');
19+
$table->integer('order');
20+
$table->string('title');
21+
$table->string('slug');
22+
$table->string('teaser');
23+
$table->longText('content')->nullable();
24+
$table->string('image');
25+
$table->json('tags')->nullable();
26+
$table->string('link')->nullable();
27+
$table->timestamps();
28+
$table->unique(['slug', 'locale']);
29+
});
30+
}
31+
32+
/**
33+
* Reverse the migrations.
34+
*/
35+
public function down(): void
36+
{
37+
Schema::dropIfExists('technologies');
38+
}
39+
};

0 commit comments

Comments
 (0)