Skip to content

Commit

Permalink
Sets up folder model and removes README.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymeh committed Oct 27, 2023
1 parent 6a33826 commit e2f5669
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 95 deletions.
12 changes: 2 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
# Creates a new folder taxonomy for Laravel projects.

[![Latest Version on Packagist](https://img.shields.io/packagist/v/creode/laravel-folder-taxonomy.svg?style=flat-square)](https://packagist.org/packages/creode/laravel-folder-taxonomy)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/creode/laravel-folder-taxonomy/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/creode/laravel-folder-taxonomy/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/creode/laravel-folder-taxonomy/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/creode/laravel-folder-taxonomy/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/creode-modules/laravel-folder-taxonomy/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/creode-modules/laravel-folder-taxonomy/actions?query=workflow%3Arun-tests+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/creode-modules/laravel-folder-taxonomy/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/creode-modules/laravel-folder-taxonomy/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/creode/laravel-folder-taxonomy.svg?style=flat-square)](https://packagist.org/packages/creode/laravel-folder-taxonomy)

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

## Support us

[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/laravel-folder-taxonomy.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/laravel-folder-taxonomy)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

## Installation

You can install the package via composer:
Expand Down
11 changes: 5 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
],
"require": {
"php": "^8.1",
"spatie/laravel-package-tools": "^1.14.0",
"illuminate/contracts": "^10.0"
"creode/laravel-taxonomy": "^1.2",
"illuminate/contracts": "^10.0",
"spatie/laravel-package-tools": "^1.14.0"
},
"require-dev": {
"laravel/pint": "^1.0",
Expand Down Expand Up @@ -70,11 +71,9 @@
"providers": [
"Creode\\LaravelFolderTaxonomy\\LaravelFolderTaxonomyServiceProvider"
],
"aliases": {
"LaravelFolderTaxonomy": "Creode\\LaravelFolderTaxonomy\\Facades\\LaravelFolderTaxonomy"
}
"aliases": {}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
21 changes: 21 additions & 0 deletions database/factories/Folder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Creode\LaravelFolderTaxonomy\Database\Factories;

use Creode\LaravelFolderTaxonomy\Models\Folder as FolderModel;
use Creode\LaravelTaxonomy\Database\Factories\TermFactory;


class Folder extends TermFactory
{
protected $model = FolderModel::class;

public function definition()
{
return [
'name' => $this->faker->word,
'slug' => $this->faker->slug,
];
// return parent::definition();
}
}
19 changes: 0 additions & 19 deletions database/factories/ModelFactory.php

This file was deleted.

6 changes: 2 additions & 4 deletions database/migrations/create_folder_taxonomy_table.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ return new class extends Migration
{
public function up()
{
Schema::create('laravel_folder_taxonomy_table', function (Blueprint $table) {
Schema::create('folders', function (Blueprint $table) {
$table->id();

// add fields

$table->baseTermFields();
$table->timestamps();
});
}
Expand Down
19 changes: 0 additions & 19 deletions src/Commands/LaravelFolderTaxonomyCommand.php

This file was deleted.

16 changes: 0 additions & 16 deletions src/Facades/LaravelFolderTaxonomy.php

This file was deleted.

7 changes: 0 additions & 7 deletions src/LaravelFolderTaxonomy.php

This file was deleted.

6 changes: 2 additions & 4 deletions src/LaravelFolderTaxonomyServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ public function configurePackage(Package $package): void
*/
$package
->name('laravel-folder-taxonomy')
->hasConfigFile()
->hasViews()
->hasMigration('create_laravel-folder-taxonomy_table')
->hasCommand(LaravelFolderTaxonomyCommand::class);
// ->hasConfigFile()
->hasMigration('create_laravel-folder-taxonomy_table');
}
}
34 changes: 34 additions & 0 deletions src/Models/Folder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace Creode\LaravelFolderTaxonomy\Models;

use Creode\LaravelTaxonomy\Models\Term;
use Creode\LaravelTaxonomy\Concerns\Parentable;
use Illuminate\Database\Eloquent\Factories\Factory;

class Folder extends Term
{
use Parentable;

/**
* Machine name of the specific term to use.
*
* @var string
*/
protected $machine_name = 'folders';

/**
* Fillable Properties for the model.
*
* @var array
*/
protected $fillable = [
'name',
'slug',
];

protected static function newFactory(): Factory
{
return \Creode\LaravelFolderTaxonomy\Database\Factories\Folder::new();
}
}
5 changes: 0 additions & 5 deletions tests/ExampleTest.php

This file was deleted.

11 changes: 11 additions & 0 deletions tests/FolderModelTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

it('can create a folder model', function () {
$folder = \Creode\LaravelFolderTaxonomy\Models\Folder::create([
'name' => 'Folder',
'slug' => 'folder',
]);

expect($folder->name)->toBe('Folder');
expect($folder->slug)->toBe('folder');
});
12 changes: 7 additions & 5 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@

namespace Creode\LaravelFolderTaxonomy\Tests;

use Creode\LaravelFolderTaxonomy\LaravelFolderTaxonomyServiceProvider;
use Illuminate\Database\Eloquent\Factories\Factory;
use Orchestra\Testbench\TestCase as Orchestra;
use Creode\LaravelFolderTaxonomy\LaravelFolderTaxonomyServiceProvider;
use Creode\LaravelTaxonomy\LaravelTaxonomyServiceProvider;

class TestCase extends Orchestra
{
protected function setUp(): void
{
parent::setUp();

$migration = include __DIR__.'/../database/migrations/create_folder_taxonomy_table.php.stub';
$migration->up();

Factory::guessFactoryNamesUsing(
fn (string $modelName) => 'Creode\\LaravelFolderTaxonomy\\Database\\Factories\\'.class_basename($modelName).'Factory'
);
Expand All @@ -20,6 +24,7 @@ protected function setUp(): void
protected function getPackageProviders($app)
{
return [
LaravelTaxonomyServiceProvider::class,
LaravelFolderTaxonomyServiceProvider::class,
];
}
Expand All @@ -28,9 +33,6 @@ public function getEnvironmentSetUp($app)
{
config()->set('database.default', 'testing');

/*
$migration = include __DIR__.'/../database/migrations/create_laravel-folder-taxonomy_table.php.stub';
$migration->up();
*/
$app->register(LaravelTaxonomyServiceProvider::class);
}
}

0 comments on commit e2f5669

Please sign in to comment.