Skip to content

Commit e53d36d

Browse files
committed
Merge branch 'main' into pr/542
2 parents 30e974e + 6d57aca commit e53d36d

File tree

385 files changed

+39682
-23937
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

385 files changed

+39682
-23937
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/node_modules
33
/node_modules.nosync
44
/public/build
5+
/public/api
56
/public/hot
67
/public/storage
78
/storage/*.key
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\Api;
4+
5+
use App\Http\Controllers\Controller;
6+
use App\Models\Author;
7+
8+
class AuthorController extends Controller
9+
{
10+
public function index()
11+
{
12+
return Author::paginate();
13+
}
14+
15+
public function show(Author $author)
16+
{
17+
return $author->append('stars_count');
18+
}
19+
}

app/Models/Author.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Models;
44

55
use Illuminate\Database\Eloquent\Builder;
6+
use Illuminate\Database\Eloquent\Casts\Attribute;
67
use Illuminate\Database\Eloquent\Factories\HasFactory;
78
use Illuminate\Database\Eloquent\Model;
89
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -63,6 +64,13 @@ public function getStarsCount(): int
6364
);
6465
}
6566

67+
protected function starsCount(): Attribute
68+
{
69+
return Attribute::make(
70+
get: fn () => $this->getStarsCount(),
71+
);
72+
}
73+
6674
public function cacheStarsCount(): void
6775
{
6876
cache()->forget($this->getStarsCountCacheKey());

build/api.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
base=$(pwd)
6+
doctum=${base}/build/doctum
7+
8+
if [ ! -f ${base}/composer.json ]; then
9+
echo "Please make sure to run this script from the root directory of this repo."
10+
exit 1
11+
fi
12+
13+
cd $doctum
14+
composer install
15+
16+
# Cleanup Before
17+
rm -rf ${doctum}/build
18+
rm -rf ${doctum}/cache
19+
rm -rf ${doctum}/filament
20+
21+
# Run API Docs
22+
git clone [email protected]:filamentphp/filament.git ${doctum}/filament
23+
24+
${doctum}/vendor/bin/doctum.php update ${doctum}/doctum.php -v --ignore-parse-errors
25+
26+
# Delete old directory before copying new one
27+
rm -rf ${base}/public/api
28+
29+
# Copy new docs to public path
30+
cp -R ${doctum}/build ${base}/public/api
31+
32+
# Cleanup After
33+
rm -rf ${doctum}/build
34+
rm -rf ${doctum}/cache
35+
rm -rf ${doctum}/filament

build/doctum/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor

build/doctum/composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": {
3+
"code-lts/doctum": "^5.5"
4+
}
5+
}

0 commit comments

Comments
 (0)