Skip to content

Commit

Permalink
updates hybridly, fixes stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
syropian committed Apr 13, 2024
1 parent a0eae42 commit 9cb29bb
Show file tree
Hide file tree
Showing 23 changed files with 3,008 additions and 1,898 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.12.2
21 changes: 10 additions & 11 deletions app/Data/DashboardData.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,30 @@
namespace App\Data;

use App\Models\User;
use Spatie\LaravelData\Attributes\DataCollectionOf;
use Illuminate\Support\Collection;
use Spatie\LaravelData\Attributes\MapOutputName;
use Spatie\LaravelData\Data;
use Spatie\LaravelData\DataCollection;
use Spatie\LaravelData\Mappers\CamelCaseMapper;

#[MapOutputName(CamelCaseMapper::class)]
class DashboardData extends Data
{
public function __construct(
#[DataCollectionOf(TagData::class)]
public DataCollection $tags,
#[DataCollectionOf(StarData::class)]
public DataCollection $stars,
#[DataCollectionOf(SmartFilterData::class)]
public DataCollection $smart_filters,
/** @var Collection<int, TagData> */
public Collection $tags,
/** @var Collection<int, StarData> */
public Collection $stars,
/** @var Collection<int, SmartFilterData> */
public Collection $smart_filters,
) {
}

public static function fromModel(User $user): self
{
return new self(
TagData::collection($user->tags()->withStarCount()->get()),
StarData::collection($user->stars()->with('tags')->get()),
SmartFilterData::collection($user->smartFilters),
TagData::collect($user->tags()->withStarCount()->get()),
StarData::collect($user->stars()->with('tags')->get()),
SmartFilterData::collect($user->smartFilters),
);
}
}
7 changes: 3 additions & 4 deletions app/Data/StarData.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

namespace App\Data;

use Spatie\LaravelData\Attributes\DataCollectionOf;
use Illuminate\Support\Collection;
use Spatie\LaravelData\Attributes\MapOutputName;
use Spatie\LaravelData\Data;
use Spatie\LaravelData\DataCollection;
use Spatie\LaravelData\Mappers\CamelCaseMapper;

class StarData extends Data
Expand All @@ -19,8 +18,8 @@ public function __construct(
public int $repo_id,
public ?string $notes,
public ?array $meta,
#[DataCollectionOf(TagData::class)]
public readonly DataCollection $tags,
/** @var Collection<int, TagData> */
public readonly Collection $tags,
) {
}
}
9 changes: 4 additions & 5 deletions app/Data/UserData.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
use App\Data\Enums\Ability;
use App\Data\Enums\Limit;
use App\Models\User;
use Spatie\LaravelData\Attributes\DataCollectionOf;
use Illuminate\Support\Collection;
use Spatie\LaravelData\Attributes\MapOutputName;
use Spatie\LaravelData\Data;
use Spatie\LaravelData\DataCollection;
use Spatie\LaravelData\Mappers\CamelCaseMapper;
use Spatie\TypeScriptTransformer\Attributes\RecordTypeScriptType;

Expand All @@ -28,8 +27,8 @@ public function __construct(
public readonly ?string $avatar,
public readonly ?bool $is_sponsor,
public readonly UserSettingsData $settings,
#[DataCollectionOf(UserFlagData::class)]
public readonly DataCollection $flags,
/** @var Collection<int, UserFlagData> */
public readonly Collection $flags,
#[RecordTypeScriptType(Limit::class, 'int')]
public readonly array $limits,
#[RecordTypeScriptType(Ability::class, 'bool')]
Expand All @@ -50,7 +49,7 @@ public static function fromModel(User $user): self
$user->avatar,
$user->is_sponsor,
UserSettingsData::from($user->settings),
UserFlagData::collection($user->flags),
UserFlagData::collect($user->flags),
$user->limits(),
[
'create_tag' => $user->can('create', Tag::class),
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"graham-campbell/github": "^12.2",
"guzzlehttp/guzzle": "^7.2",
"http-interop/http-factory-guzzle": "^1.0",
"hybridly/laravel": "^0.3.1",
"hybridly/laravel": "^0.7.3",
"laravel/framework": "^10.10",
"laravel/sanctum": "^3.2",
"laravel/socialite": "^5.6",
"laravel/tinker": "^2.8",
"spatie/laravel-data": "^3.6"
"spatie/laravel-data": "^4.0"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.8",
Expand Down
Loading

0 comments on commit 9cb29bb

Please sign in to comment.