Skip to content

Commit c890272

Browse files
committed
wip
1 parent fd06dee commit c890272

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

app/Filament/Resources/Posts/PostResource.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@
2424
use Filament\Forms\Components\DateTimePicker;
2525
use Filament\Forms\Components\MarkdownEditor;
2626
use Filament\Forms\Components\SpatieTagsInput;
27+
use Filament\Forms\Components\Textarea;
2728
use Filament\Forms\Components\TextInput;
2829
use Filament\Forms\Components\Toggle;
2930
use Filament\Resources\Resource;
3031
use Filament\Schemas\Components\Actions;
3132
use Filament\Schemas\Components\Flex;
3233
use Filament\Schemas\Components\Section;
34+
use Filament\Schemas\Components\Utilities\Get;
3335
use Filament\Schemas\Components\Utilities\Set;
3436
use Filament\Schemas\Schema;
3537
use Filament\Tables\Columns\IconColumn;
@@ -73,6 +75,12 @@ public static function form(Schema $schema): Schema
7375

7476
SpatieTagsInput::make('tags'),
7577

78+
Textarea::make('excerpt')
79+
->rows(3)
80+
->maxLength(500)
81+
->live(debounce: 200)
82+
->helperText(fn (Get $get): string => mb_strlen($get('excerpt') ?? '').'/500 characters'),
83+
7684
MarkdownEditor::make('text')
7785
->fileAttachmentsDirectory('posts')
7886
->required(),

app/Models/Post.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ final class Post extends Model implements HasMedia, Sitemapable
4040
* @var list<string>
4141
*/
4242
protected $fillable = [
43-
'title', 'slug', 'text', 'is_published', 'published_at',
43+
'title', 'slug', 'excerpt', 'text', 'is_published', 'published_at',
4444
'posted_on_twitter', 'posted_on_dev', 'posted_on_threads',
4545
];
4646

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Illuminate\Database\Migrations\Migration;
6+
use Illuminate\Database\Schema\Blueprint;
7+
use Illuminate\Support\Facades\Schema;
8+
9+
return new class extends Migration
10+
{
11+
/**
12+
* Run the migrations.
13+
*/
14+
public function up(): void
15+
{
16+
Schema::table('posts', function (Blueprint $table): void {
17+
$table->string('excerpt', 500)->after('body');
18+
});
19+
}
20+
21+
/**
22+
* Reverse the migrations.
23+
*/
24+
public function down(): void
25+
{
26+
Schema::table('posts', function (Blueprint $table): void {
27+
$table->dropColumn('excerpt');
28+
});
29+
}
30+
};

0 commit comments

Comments
 (0)