refactor: rename 'title' to 'name' in Category model, requests, factories, migrations, and seeders for consistency
This commit is contained in:
parent
bfee01153c
commit
678e693f00
@ -23,7 +23,7 @@ public function authorize(): bool
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'title' => ['required', 'string', 'max:50'],
|
||||
'name' => ['required', 'string', 'max:50'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ protected function inactive(Builder $query): void
|
||||
public function getSlugOptions(): SlugOptions
|
||||
{
|
||||
return SlugOptions::create()
|
||||
->generateSlugsFrom('title')
|
||||
->generateSlugsFrom('name')
|
||||
->saveSlugsTo('slug');
|
||||
}
|
||||
|
||||
|
||||
@ -17,11 +17,11 @@ class CategoryFactory extends Factory
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$title = str()->limit($this->faker->sentence, 40);
|
||||
$name = str()->limit($this->faker->sentence, 40);
|
||||
|
||||
return [
|
||||
'title' => $title,
|
||||
'slug' => str()->slug($title),
|
||||
'name' => $name,
|
||||
'slug' => str()->slug($name),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ public function up(): void
|
||||
{
|
||||
Schema::create('categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title', 50);
|
||||
$table->string('name', 50);
|
||||
$table->string('slug', 50);
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
|
||||
@ -13,10 +13,10 @@ class CategorySeeder extends Seeder
|
||||
public function run(): void
|
||||
{
|
||||
$categories = [
|
||||
['title' => 'Set Celana', 'slug' => 'set-celana', 'is_active' => true],
|
||||
['title' => 'Gamis', 'slug' => 'gamis', 'is_active' => true],
|
||||
['title' => 'Mukena', 'slug' => 'mukena', 'is_active' => true],
|
||||
['title' => 'Dress', 'slug' => 'dress', 'is_active' => true],
|
||||
['name' => 'Set Celana', 'slug' => 'set-celana', 'is_active' => true],
|
||||
['name' => 'Gamis', 'slug' => 'gamis', 'is_active' => true],
|
||||
['name' => 'Mukena', 'slug' => 'mukena', 'is_active' => true],
|
||||
['name' => 'Dress', 'slug' => 'dress', 'is_active' => true],
|
||||
];
|
||||
|
||||
foreach ($categories as $category) {
|
||||
|
||||
@ -99,7 +99,7 @@ export default function ProductCreate({ categories }: { categories: Category[] }
|
||||
<>
|
||||
{values.map((value) => (
|
||||
<ComboboxChip key={value.id}>
|
||||
{value.title}
|
||||
{value.name}
|
||||
</ComboboxChip>
|
||||
))}
|
||||
<ComboboxChipsInput placeholder='Pilih Kategori' />
|
||||
@ -112,7 +112,7 @@ export default function ProductCreate({ categories }: { categories: Category[] }
|
||||
<ComboboxList>
|
||||
{(item: Category) => (
|
||||
<ComboboxItem key={item.id} value={item}>
|
||||
{item.title}
|
||||
{item.name}
|
||||
</ComboboxItem>
|
||||
)}
|
||||
</ComboboxList>
|
||||
|
||||
@ -107,7 +107,7 @@ export default function ProductEdit({ product, categories }: { product: Product,
|
||||
<>
|
||||
{values.map((value) => (
|
||||
<ComboboxChip key={value.id}>
|
||||
{value.title}
|
||||
{value.name}
|
||||
</ComboboxChip>
|
||||
))}
|
||||
<ComboboxChipsInput placeholder='Pilih Kategori' />
|
||||
@ -120,7 +120,7 @@ export default function ProductEdit({ product, categories }: { product: Product,
|
||||
<ComboboxList>
|
||||
{(item: Category) => (
|
||||
<ComboboxItem key={item.id} value={item}>
|
||||
{item.title}
|
||||
{item.name}
|
||||
</ComboboxItem>
|
||||
)}
|
||||
</ComboboxList>
|
||||
|
||||
@ -94,7 +94,7 @@ export default function ProductIndex({ products }: { products: Product[] }) {
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{product.categories?.map((category) => (
|
||||
<Badge key={category.id} variant="secondary">
|
||||
{category.title}
|
||||
{category.name}
|
||||
</Badge>
|
||||
))}
|
||||
{(!product.categories || product.categories.length === 0) && (
|
||||
|
||||
Loading…
Reference in New Issue
Block a user