refactor: rename 'title' to 'name' in Category model, requests, factories, migrations, and seeders for consistency

This commit is contained in:
Yoga Pangestu 2026-04-16 13:19:04 +07:00
parent bfee01153c
commit 678e693f00
8 changed files with 15 additions and 15 deletions

View File

@ -23,7 +23,7 @@ public function authorize(): bool
public function rules(): array public function rules(): array
{ {
return [ return [
'title' => ['required', 'string', 'max:50'], 'name' => ['required', 'string', 'max:50'],
]; ];
} }
} }

View File

@ -39,7 +39,7 @@ protected function inactive(Builder $query): void
public function getSlugOptions(): SlugOptions public function getSlugOptions(): SlugOptions
{ {
return SlugOptions::create() return SlugOptions::create()
->generateSlugsFrom('title') ->generateSlugsFrom('name')
->saveSlugsTo('slug'); ->saveSlugsTo('slug');
} }

View File

@ -17,11 +17,11 @@ class CategoryFactory extends Factory
*/ */
public function definition(): array public function definition(): array
{ {
$title = str()->limit($this->faker->sentence, 40); $name = str()->limit($this->faker->sentence, 40);
return [ return [
'title' => $title, 'name' => $name,
'slug' => str()->slug($title), 'slug' => str()->slug($name),
]; ];
} }
} }

View File

@ -13,7 +13,7 @@ public function up(): void
{ {
Schema::create('categories', function (Blueprint $table) { Schema::create('categories', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('title', 50); $table->string('name', 50);
$table->string('slug', 50); $table->string('slug', 50);
$table->boolean('is_active')->default(true); $table->boolean('is_active')->default(true);
$table->timestamp('created_at')->useCurrent(); $table->timestamp('created_at')->useCurrent();

View File

@ -13,10 +13,10 @@ class CategorySeeder extends Seeder
public function run(): void public function run(): void
{ {
$categories = [ $categories = [
['title' => 'Set Celana', 'slug' => 'set-celana', 'is_active' => true], ['name' => 'Set Celana', 'slug' => 'set-celana', 'is_active' => true],
['title' => 'Gamis', 'slug' => 'gamis', 'is_active' => true], ['name' => 'Gamis', 'slug' => 'gamis', 'is_active' => true],
['title' => 'Mukena', 'slug' => 'mukena', 'is_active' => true], ['name' => 'Mukena', 'slug' => 'mukena', 'is_active' => true],
['title' => 'Dress', 'slug' => 'dress', 'is_active' => true], ['name' => 'Dress', 'slug' => 'dress', 'is_active' => true],
]; ];
foreach ($categories as $category) { foreach ($categories as $category) {

View File

@ -99,7 +99,7 @@ export default function ProductCreate({ categories }: { categories: Category[] }
<> <>
{values.map((value) => ( {values.map((value) => (
<ComboboxChip key={value.id}> <ComboboxChip key={value.id}>
{value.title} {value.name}
</ComboboxChip> </ComboboxChip>
))} ))}
<ComboboxChipsInput placeholder='Pilih Kategori' /> <ComboboxChipsInput placeholder='Pilih Kategori' />
@ -112,7 +112,7 @@ export default function ProductCreate({ categories }: { categories: Category[] }
<ComboboxList> <ComboboxList>
{(item: Category) => ( {(item: Category) => (
<ComboboxItem key={item.id} value={item}> <ComboboxItem key={item.id} value={item}>
{item.title} {item.name}
</ComboboxItem> </ComboboxItem>
)} )}
</ComboboxList> </ComboboxList>

View File

@ -107,7 +107,7 @@ export default function ProductEdit({ product, categories }: { product: Product,
<> <>
{values.map((value) => ( {values.map((value) => (
<ComboboxChip key={value.id}> <ComboboxChip key={value.id}>
{value.title} {value.name}
</ComboboxChip> </ComboboxChip>
))} ))}
<ComboboxChipsInput placeholder='Pilih Kategori' /> <ComboboxChipsInput placeholder='Pilih Kategori' />
@ -120,7 +120,7 @@ export default function ProductEdit({ product, categories }: { product: Product,
<ComboboxList> <ComboboxList>
{(item: Category) => ( {(item: Category) => (
<ComboboxItem key={item.id} value={item}> <ComboboxItem key={item.id} value={item}>
{item.title} {item.name}
</ComboboxItem> </ComboboxItem>
)} )}
</ComboboxList> </ComboboxList>

View File

@ -94,7 +94,7 @@ export default function ProductIndex({ products }: { products: Product[] }) {
<div className="flex flex-wrap gap-1"> <div className="flex flex-wrap gap-1">
{product.categories?.map((category) => ( {product.categories?.map((category) => (
<Badge key={category.id} variant="secondary"> <Badge key={category.id} variant="secondary">
{category.title} {category.name}
</Badge> </Badge>
))} ))}
{(!product.categories || product.categories.length === 0) && ( {(!product.categories || product.categories.length === 0) && (