diff --git a/app/Http/Controllers/ClassificationController.php b/app/Http/Controllers/ClassificationController.php new file mode 100644 index 0000000..b8b8c4d --- /dev/null +++ b/app/Http/Controllers/ClassificationController.php @@ -0,0 +1,63 @@ + Classification::paginate(), + ]); + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + $request->validate([ + 'name' => 'required|string|max:255' + ]); + + Classification::create(['name' => $request->name]); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, Classification $classification) + { + $request->validate([ + 'name' => 'required|string|max:255' + ]); + + $classification->update(['name' => $request->name]); + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy(Classification $classification) + { + $classification->delete(); + } +} diff --git a/app/Http/Controllers/DocumentController.php b/app/Http/Controllers/DocumentController.php index 5bb028a..626fca3 100644 --- a/app/Http/Controllers/DocumentController.php +++ b/app/Http/Controllers/DocumentController.php @@ -18,7 +18,7 @@ class DocumentController extends Controller { public function index(Request $request) { - $query = Document::with(['variety', 'category']); + $query = Document::with(['variety', 'category', 'company']); if ($request->has('status')) { if($request->status == 1) { diff --git a/app/Http/Controllers/TypeController.php b/app/Http/Controllers/TypeController.php index 7f4478d..d6509d6 100644 --- a/app/Http/Controllers/TypeController.php +++ b/app/Http/Controllers/TypeController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Models\Classification; use App\Models\Type; use Illuminate\Http\Request; @@ -15,7 +16,8 @@ class TypeController extends Controller public function index() { return inertia('Type/Index', [ - 'types' => Type::paginate(), + 'types' => Type::with(['classification'])->paginate(), + 'classifications' => Classification::all() ]); } @@ -28,10 +30,14 @@ class TypeController extends Controller public function store(Request $request) { $request->validate([ - 'name' => 'required|string|max:255' + 'name' => 'required|string|max:255', + 'classification_id' => 'required|exists:classifications,id' ]); - Type::create(['name' => $request->name]); + Type::create([ + 'name' => $request->name, + 'classification_id' => $request->classification_id + ]); } /** @@ -44,10 +50,14 @@ class TypeController extends Controller public function update(Request $request, Type $type) { $request->validate([ - 'name' => 'required|string|max:255' + 'name' => 'required|string|max:255', + 'classification_id' => 'required|exists:classifications,id' ]); - $type->update(['name' => $request->name]); + $type->update([ + 'name' => $request->name, + 'classification_id' => $request->classification_id + ]); } /** diff --git a/app/Models/Classification.php b/app/Models/Classification.php new file mode 100644 index 0000000..cba1fbd --- /dev/null +++ b/app/Models/Classification.php @@ -0,0 +1,21 @@ +hasMany(Type::class); + } +} diff --git a/app/Models/Type.php b/app/Models/Type.php index 9a18219..74ce8ca 100644 --- a/app/Models/Type.php +++ b/app/Models/Type.php @@ -12,6 +12,7 @@ class Type extends Model protected $fillable = [ "name", + 'classification_id' ]; protected $cascadeDeletes = ['documents']; @@ -21,4 +22,9 @@ class Type extends Model return $this->hasMany(Document::class); } + public function classification() + { + return $this->belongsTo(Classification::class); + } + } diff --git a/composer.lock b/composer.lock index 7ae1a15..dbe81e7 100644 --- a/composer.lock +++ b/composer.lock @@ -8,26 +8,26 @@ "packages": [ { "name": "barryvdh/laravel-dompdf", - "version": "v2.0.0", + "version": "v2.0.1", "source": { "type": "git", "url": "https://github.com/barryvdh/laravel-dompdf.git", - "reference": "1d47648c6cef37f715ecb8bcc5f5a656ad372e27" + "reference": "9843d2be423670fb434f4c978b3c0f4dd92c87a6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/barryvdh/laravel-dompdf/zipball/1d47648c6cef37f715ecb8bcc5f5a656ad372e27", - "reference": "1d47648c6cef37f715ecb8bcc5f5a656ad372e27", + "url": "https://api.github.com/repos/barryvdh/laravel-dompdf/zipball/9843d2be423670fb434f4c978b3c0f4dd92c87a6", + "reference": "9843d2be423670fb434f4c978b3c0f4dd92c87a6", "shasum": "" }, "require": { - "dompdf/dompdf": "^2", - "illuminate/support": "^6|^7|^8|^9", + "dompdf/dompdf": "^2.0.1", + "illuminate/support": "^6|^7|^8|^9|^10", "php": "^7.2 || ^8.0" }, "require-dev": { "nunomaduro/larastan": "^1|^2", - "orchestra/testbench": "^4|^5|^6|^7", + "orchestra/testbench": "^4|^5|^6|^7|^8", "phpro/grumphp": "^1", "squizlabs/php_codesniffer": "^3.5" }, @@ -69,7 +69,7 @@ ], "support": { "issues": "https://github.com/barryvdh/laravel-dompdf/issues", - "source": "https://github.com/barryvdh/laravel-dompdf/tree/v2.0.0" + "source": "https://github.com/barryvdh/laravel-dompdf/tree/v2.0.1" }, "funding": [ { @@ -81,30 +81,29 @@ "type": "github" } ], - "time": "2022-07-06T11:12:10+00:00" + "time": "2023-01-12T15:12:49+00:00" }, { "name": "brick/math", - "version": "0.10.2", + "version": "0.11.0", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "459f2781e1a08d52ee56b0b1444086e038561e3f" + "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/459f2781e1a08d52ee56b0b1444086e038561e3f", - "reference": "459f2781e1a08d52ee56b0b1444086e038561e3f", + "url": "https://api.github.com/repos/brick/math/zipball/0ad82ce168c82ba30d1c01ec86116ab52f589478", + "reference": "0ad82ce168c82ba30d1c01ec86116ab52f589478", "shasum": "" }, "require": { - "ext-json": "*", - "php": "^7.4 || ^8.0" + "php": "^8.0" }, "require-dev": { "php-coveralls/php-coveralls": "^2.2", "phpunit/phpunit": "^9.0", - "vimeo/psalm": "4.25.0" + "vimeo/psalm": "5.0.0" }, "type": "library", "autoload": { @@ -129,7 +128,7 @@ ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.10.2" + "source": "https://github.com/brick/math/tree/0.11.0" }, "funding": [ { @@ -137,7 +136,7 @@ "type": "github" } ], - "time": "2022-08-10T22:54:19+00:00" + "time": "2023-01-15T23:15:59+00:00" }, { "name": "composer/semver", @@ -465,16 +464,16 @@ }, { "name": "dompdf/dompdf", - "version": "v2.0.1", + "version": "v2.0.2", "source": { "type": "git", "url": "https://github.com/dompdf/dompdf.git", - "reference": "c5310df0e22c758c85ea5288175fc6cd777bc085" + "reference": "ad4c631bf8897fc1ca7b566468a969cfd71a558a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dompdf/dompdf/zipball/c5310df0e22c758c85ea5288175fc6cd777bc085", - "reference": "c5310df0e22c758c85ea5288175fc6cd777bc085", + "url": "https://api.github.com/repos/dompdf/dompdf/zipball/ad4c631bf8897fc1ca7b566468a969cfd71a558a", + "reference": "ad4c631bf8897fc1ca7b566468a969cfd71a558a", "shasum": "" }, "require": { @@ -521,9 +520,9 @@ "homepage": "https://github.com/dompdf/dompdf", "support": { "issues": "https://github.com/dompdf/dompdf/issues", - "source": "https://github.com/dompdf/dompdf/tree/v2.0.1" + "source": "https://github.com/dompdf/dompdf/tree/v2.0.2" }, - "time": "2022-09-22T13:43:41+00:00" + "time": "2023-01-31T13:30:40+00:00" }, { "name": "dragonmantank/cron-expression", @@ -1252,21 +1251,21 @@ }, { "name": "laravel/framework", - "version": "v9.48.0", + "version": "v9.50.1", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "c78ae7aeb0cbcb1a205050d3592247ba07f5b711" + "reference": "3b400f76619cd5257a69fdd6b897043b6522a89a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/c78ae7aeb0cbcb1a205050d3592247ba07f5b711", - "reference": "c78ae7aeb0cbcb1a205050d3592247ba07f5b711", + "url": "https://api.github.com/repos/laravel/framework/zipball/3b400f76619cd5257a69fdd6b897043b6522a89a", + "reference": "3b400f76619cd5257a69fdd6b897043b6522a89a", "shasum": "" }, "require": { - "brick/math": "^0.10.2", - "doctrine/inflector": "^2.0", + "brick/math": "^0.9.3|^0.10.2|^0.11", + "doctrine/inflector": "^2.0.5", "dragonmantank/cron-expression": "^3.3.2", "egulias/email-validator": "^3.2.1|^4.0", "ext-mbstring": "*", @@ -1365,7 +1364,6 @@ "aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage, and SES mail driver (^3.235.5).", "brianium/paratest": "Required to run tests in parallel (^6.0).", "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.13.3|^3.1.4).", - "ext-bcmath": "Required to use the multiple_of validation rule.", "ext-ftp": "Required to use the Flysystem FTP driver.", "ext-gd": "Required to use Illuminate\\Http\\Testing\\FileFactory::image().", "ext-memcached": "Required to use the memcache cache driver.", @@ -1437,7 +1435,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2023-01-17T15:06:19+00:00" + "time": "2023-02-01T17:36:26+00:00" }, { "name": "laravel/sanctum", @@ -1506,16 +1504,16 @@ }, { "name": "laravel/serializable-closure", - "version": "v1.2.2", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/laravel/serializable-closure.git", - "reference": "47afb7fae28ed29057fdca37e16a84f90cc62fae" + "reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/47afb7fae28ed29057fdca37e16a84f90cc62fae", - "reference": "47afb7fae28ed29057fdca37e16a84f90cc62fae", + "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/f23fe9d4e95255dacee1bf3525e0810d1a1b0f37", + "reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37", "shasum": "" }, "require": { @@ -1562,7 +1560,7 @@ "issues": "https://github.com/laravel/serializable-closure/issues", "source": "https://github.com/laravel/serializable-closure" }, - "time": "2022-09-08T13:45:54+00:00" + "time": "2023-01-30T18:31:20+00:00" }, { "name": "laravel/tinker", @@ -2468,16 +2466,16 @@ }, { "name": "nesbot/carbon", - "version": "2.65.0", + "version": "2.66.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "09acf64155c16dc6f580f36569ae89344e9734a3" + "reference": "496712849902241f04902033b0441b269effe001" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/09acf64155c16dc6f580f36569ae89344e9734a3", - "reference": "09acf64155c16dc6f580f36569ae89344e9734a3", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/496712849902241f04902033b0441b269effe001", + "reference": "496712849902241f04902033b0441b269effe001", "shasum": "" }, "require": { @@ -2566,7 +2564,7 @@ "type": "tidelift" } ], - "time": "2023-01-06T15:55:01+00:00" + "time": "2023-01-29T18:53:47+00:00" }, { "name": "nette/schema", @@ -2632,29 +2630,30 @@ }, { "name": "nette/utils", - "version": "v3.2.9", + "version": "v4.0.0", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "c91bac3470c34b2ecd5400f6e6fdf0b64a836a5c" + "reference": "cacdbf5a91a657ede665c541eda28941d4b09c1e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/c91bac3470c34b2ecd5400f6e6fdf0b64a836a5c", - "reference": "c91bac3470c34b2ecd5400f6e6fdf0b64a836a5c", + "url": "https://api.github.com/repos/nette/utils/zipball/cacdbf5a91a657ede665c541eda28941d4b09c1e", + "reference": "cacdbf5a91a657ede665c541eda28941d4b09c1e", "shasum": "" }, "require": { - "php": ">=7.2 <8.3" + "php": ">=8.0 <8.3" }, "conflict": { - "nette/di": "<3.0.6" + "nette/finder": "<3", + "nette/schema": "<1.2.2" }, "require-dev": { "jetbrains/phpstorm-attributes": "dev-master", - "nette/tester": "~2.0", + "nette/tester": "^2.4", "phpstan/phpstan": "^1.0", - "tracy/tracy": "^2.3" + "tracy/tracy": "^2.9" }, "suggest": { "ext-gd": "to use Image", @@ -2668,7 +2667,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -2712,9 +2711,9 @@ ], "support": { "issues": "https://github.com/nette/utils/issues", - "source": "https://github.com/nette/utils/tree/v3.2.9" + "source": "https://github.com/nette/utils/tree/v4.0.0" }, - "time": "2023-01-18T03:26:20+00:00" + "time": "2023-02-02T10:41:53+00:00" }, { "name": "nikic/php-parser", @@ -3583,16 +3582,16 @@ }, { "name": "psy/psysh", - "version": "v0.11.11", + "version": "v0.11.12", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "ba67f2d26278ec9266a5cfe0acba33a8ca1277ae" + "reference": "52cb7c47d403c31c0adc9bf7710fc355f93c20f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/ba67f2d26278ec9266a5cfe0acba33a8ca1277ae", - "reference": "ba67f2d26278ec9266a5cfe0acba33a8ca1277ae", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/52cb7c47d403c31c0adc9bf7710fc355f93c20f7", + "reference": "52cb7c47d403c31c0adc9bf7710fc355f93c20f7", "shasum": "" }, "require": { @@ -3653,9 +3652,9 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.11.11" + "source": "https://github.com/bobthecow/psysh/tree/v0.11.12" }, - "time": "2023-01-23T16:14:59+00:00" + "time": "2023-01-29T21:24:40+00:00" }, { "name": "ralouphie/getallheaders", @@ -3792,20 +3791,20 @@ }, { "name": "ramsey/uuid", - "version": "4.7.3", + "version": "4.x-dev", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "433b2014e3979047db08a17a205f410ba3869cf2" + "reference": "25c4faac19549ebfcd3a6a73732dddeb188eaf5a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/433b2014e3979047db08a17a205f410ba3869cf2", - "reference": "433b2014e3979047db08a17a205f410ba3869cf2", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/25c4faac19549ebfcd3a6a73732dddeb188eaf5a", + "reference": "25c4faac19549ebfcd3a6a73732dddeb188eaf5a", "shasum": "" }, "require": { - "brick/math": "^0.8.8 || ^0.9 || ^0.10", + "brick/math": "^0.8.8 || ^0.9 || ^0.10 || ^0.11", "ext-json": "*", "php": "^8.0", "ramsey/collection": "^1.2 || ^2.0" @@ -3842,6 +3841,7 @@ "paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter", "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type." }, + "default-branch": true, "type": "library", "extra": { "captainhook": { @@ -3868,7 +3868,7 @@ ], "support": { "issues": "https://github.com/ramsey/uuid/issues", - "source": "https://github.com/ramsey/uuid/tree/4.7.3" + "source": "https://github.com/ramsey/uuid/tree/4.x" }, "funding": [ { @@ -3880,7 +3880,7 @@ "type": "tidelift" } ], - "time": "2023-01-12T18:13:24+00:00" + "time": "2023-01-28T17:00:47+00:00" }, { "name": "rap2hpoutre/fast-excel", @@ -4589,16 +4589,16 @@ }, { "name": "symfony/http-foundation", - "version": "v6.2.5", + "version": "v6.2.6", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "9d081ead9d3432e2e8002178d14c4c9dd4b8ffbf" + "reference": "e8dd1f502bc2b3371d05092aa233b064b03ce7ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/9d081ead9d3432e2e8002178d14c4c9dd4b8ffbf", - "reference": "9d081ead9d3432e2e8002178d14c4c9dd4b8ffbf", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/e8dd1f502bc2b3371d05092aa233b064b03ce7ed", + "reference": "e8dd1f502bc2b3371d05092aa233b064b03ce7ed", "shasum": "" }, "require": { @@ -4647,7 +4647,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v6.2.5" + "source": "https://github.com/symfony/http-foundation/tree/v6.2.6" }, "funding": [ { @@ -4663,20 +4663,20 @@ "type": "tidelift" } ], - "time": "2023-01-01T08:38:09+00:00" + "time": "2023-01-30T15:46:28+00:00" }, { "name": "symfony/http-kernel", - "version": "v6.2.5", + "version": "v6.2.6", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "f68aaa11eee6b21c99bce0f3d98815924888fe62" + "reference": "7122db07b0d8dbf0de682267c84217573aee3ea7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/f68aaa11eee6b21c99bce0f3d98815924888fe62", - "reference": "f68aaa11eee6b21c99bce0f3d98815924888fe62", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/7122db07b0d8dbf0de682267c84217573aee3ea7", + "reference": "7122db07b0d8dbf0de682267c84217573aee3ea7", "shasum": "" }, "require": { @@ -4758,7 +4758,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v6.2.5" + "source": "https://github.com/symfony/http-kernel/tree/v6.2.6" }, "funding": [ { @@ -4774,7 +4774,7 @@ "type": "tidelift" } ], - "time": "2023-01-24T15:33:24+00:00" + "time": "2023-02-01T08:32:25+00:00" }, { "name": "symfony/mailer", @@ -6922,16 +6922,16 @@ }, { "name": "laravel/breeze", - "version": "v1.18.0", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/laravel/breeze.git", - "reference": "4280282cff1ed240d6494bbb3405635820a09931" + "reference": "bed2fb2a8a4131be37cc3556826cca961db3406a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/breeze/zipball/4280282cff1ed240d6494bbb3405635820a09931", - "reference": "4280282cff1ed240d6494bbb3405635820a09931", + "url": "https://api.github.com/repos/laravel/breeze/zipball/bed2fb2a8a4131be37cc3556826cca961db3406a", + "reference": "bed2fb2a8a4131be37cc3556826cca961db3406a", "shasum": "" }, "require": { @@ -6979,20 +6979,20 @@ "issues": "https://github.com/laravel/breeze/issues", "source": "https://github.com/laravel/breeze" }, - "time": "2023-01-17T14:08:34+00:00" + "time": "2023-01-31T16:16:21+00:00" }, { "name": "laravel/pint", - "version": "v1.4.0", + "version": "v1.4.1", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "0e7ffdb0af871be10d798e234772ea5d4020ae4a" + "reference": "80ddf23a5d97825e79bb1018eebb6f3f985d4fa8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/0e7ffdb0af871be10d798e234772ea5d4020ae4a", - "reference": "0e7ffdb0af871be10d798e234772ea5d4020ae4a", + "url": "https://api.github.com/repos/laravel/pint/zipball/80ddf23a5d97825e79bb1018eebb6f3f985d4fa8", + "reference": "80ddf23a5d97825e79bb1018eebb6f3f985d4fa8", "shasum": "" }, "require": { @@ -7003,7 +7003,7 @@ "php": "^8.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "~3.13.1", + "friendsofphp/php-cs-fixer": "^3.14", "illuminate/view": "^9.32.0", "laravel-zero/framework": "^9.2.0", "mockery/mockery": "^1.5.1", @@ -7045,20 +7045,20 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2023-01-10T20:03:42+00:00" + "time": "2023-01-31T15:50:45+00:00" }, { "name": "laravel/sail", - "version": "v1.18.1", + "version": "v1.19.0", "source": { "type": "git", "url": "https://github.com/laravel/sail.git", - "reference": "a64f78a4ab86c04a4c5de39bea20a8d36ad48a22" + "reference": "4f230634a3163f3442def6a4e6ffdb02b02e14d6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/sail/zipball/a64f78a4ab86c04a4c5de39bea20a8d36ad48a22", - "reference": "a64f78a4ab86c04a4c5de39bea20a8d36ad48a22", + "url": "https://api.github.com/repos/laravel/sail/zipball/4f230634a3163f3442def6a4e6ffdb02b02e14d6", + "reference": "4f230634a3163f3442def6a4e6ffdb02b02e14d6", "shasum": "" }, "require": { @@ -7105,7 +7105,7 @@ "issues": "https://github.com/laravel/sail/issues", "source": "https://github.com/laravel/sail" }, - "time": "2023-01-11T14:35:04+00:00" + "time": "2023-01-31T13:37:57+00:00" }, { "name": "mockery/mockery", @@ -7439,16 +7439,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.23", + "version": "9.2.24", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c" + "reference": "2cf940ebc6355a9d430462811b5aaa308b174bed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c", - "reference": "9f1f0f9a2fbb680b26d1cf9b61b6eac43a6e4e9c", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2cf940ebc6355a9d430462811b5aaa308b174bed", + "reference": "2cf940ebc6355a9d430462811b5aaa308b174bed", "shasum": "" }, "require": { @@ -7504,7 +7504,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.23" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.24" }, "funding": [ { @@ -7512,7 +7512,7 @@ "type": "github" } ], - "time": "2022-12-28T12:41:10+00:00" + "time": "2023-01-26T08:26:55+00:00" }, { "name": "phpunit/php-file-iterator", diff --git a/database/migrations/2022_01_26_015830_create_types_table.php b/database/migrations/2022_01_26_015830_create_types_table.php index 0d469f0..962c59e 100644 --- a/database/migrations/2022_01_26_015830_create_types_table.php +++ b/database/migrations/2022_01_26_015830_create_types_table.php @@ -16,6 +16,7 @@ return new class extends Migration Schema::create('types', function (Blueprint $table) { $table->id(); $table->string('name'); + $table->bigInteger('classification_id')->nullable(); $table->timestamps(); }); } diff --git a/database/migrations/2023_02_02_200546_create_classifications_table.php b/database/migrations/2023_02_02_200546_create_classifications_table.php new file mode 100644 index 0000000..fc92c3a --- /dev/null +++ b/database/migrations/2023_02_02_200546_create_classifications_table.php @@ -0,0 +1,32 @@ +id(); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('classifications'); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index b2d878d..f2cdf06 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -5,6 +5,7 @@ namespace Database\Seeders; // use Illuminate\Database\Console\Seeds\WithoutModelEvents; use App\Models\Category; +use App\Models\Classification; use App\Models\Company; use App\Models\Department; use App\Models\Group; @@ -78,6 +79,10 @@ class DatabaseSeeder extends Seeder ['name' => 'update-company', 'label' => 'Edit Perusahaan'], ['name' => 'create-company', 'label' => 'Buat Perusahaan'], ['name' => 'delete-company', 'label' => 'Hapus Perusahaan'], + ['name' => 'view-classification', 'label' => 'Lihat Klasifikasi'], + ['name' => 'update-classification', 'label' => 'Edit Klasifikasi'], + ['name' => 'create-classification', 'label' => 'Buat Klasifikasi'], + ['name' => 'delete-classification', 'label' => 'Hapus Klasifikasi'], ['name' => 'view-setting', 'label' => 'Setting'], ]; @@ -96,7 +101,8 @@ class DatabaseSeeder extends Seeder ]); - Type::create(['name' => 'Type 1']); + $classification = Classification::create(['name' => 'Klasifikasi 1']); + Type::create(['name' => 'Type 1', 'classification_id' => $classification->id]); Category::create(['name' => 'Category 1', 'short' => 'C1', 'duration' => 3]); Setting::create([ diff --git a/resources/css/app.css b/resources/css/app.css index f26cddf..d3954d8 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -2,6 +2,12 @@ @tailwind components; @tailwind utilities; +.table td, .table th { + padding: 1rem; + vertical-align: middle; + white-space: normal; +} + /* width */ ::-webkit-scrollbar { width: 5px; diff --git a/resources/js/Layouts/AuthenticatedLayout.jsx b/resources/js/Layouts/AuthenticatedLayout.jsx index 8e7938e..8ead4bc 100644 --- a/resources/js/Layouts/AuthenticatedLayout.jsx +++ b/resources/js/Layouts/AuthenticatedLayout.jsx @@ -11,6 +11,7 @@ const rs = [ {name: "Dokumen", show: true, items: [ {name: "Dokumen", route: 'docs.index', show: true, permission: 'view-document'}, {name: "Ketegori", route: 'categories.index', show: true, permission: 'view-category'}, + {name: "Klasifikasi", route: 'classifications.index', show: true, permission: 'view-classification'}, {name: "Jenis", route: 'types.index', show: true, permission: 'view-type'}, ]}, {name: "Perusahaan", show: true, items: [ diff --git a/resources/js/Pages/Classification/FormModal.jsx b/resources/js/Pages/Classification/FormModal.jsx new file mode 100644 index 0000000..4ee51ca --- /dev/null +++ b/resources/js/Pages/Classification/FormModal.jsx @@ -0,0 +1,112 @@ +import React, { useEffect } from 'react' +import { useForm, usePage } from '@inertiajs/react' +import { toast } from 'react-toastify' + +export default function FormModal(props) { + const { modalState } = props + + const { data, setData, post, put, processing, errors, reset, clearErrors } = useForm({ + name: '', + }) + + const handleOnChange = (event) => { + setData(event.target.name, event.target.type === 'checkbox' ? event.target.checked : event.target.value); + } + + const handleReset = () => { + reset() + clearErrors() + modalState.setData(null) + } + + const handleCancel = () => { + handleReset() + modalState.toggle() + } + + const handleSubmit = () => { + const classification = modalState.data + if(classification !== null) { + put(route('classifications.update', classification), { + onSuccess: () => + Promise.all([ + handleReset(), + modalState.toggle(), + toast.success('The Data has been changed'), + ]), + }) + return + } + post(route('classifications.store'), { + onSuccess: () => + Promise.all([ + handleReset(), + modalState.toggle(), + toast.success('The Data has been saved'), + ]), + }) + } + + useEffect(() => { + const classification = modalState.data + if (classification !== null) { + setData({ + name: classification?.name, + }) + } + }, [modalState]) + + return ( +
+
+

Klasifikasi

+
+ + + +
+
+
+ Simpan +
+
+ Batal +
+
+
+
+ ) +} \ No newline at end of file diff --git a/resources/js/Pages/Classification/Index.jsx b/resources/js/Pages/Classification/Index.jsx new file mode 100644 index 0000000..a14dd04 --- /dev/null +++ b/resources/js/Pages/Classification/Index.jsx @@ -0,0 +1,118 @@ +import React from 'react' +import { Head } from '@inertiajs/react' +import { router } from '@inertiajs/react' +import { toast } from 'react-toastify' + +import { useModalState } from '@/Hooks' +import { hasPermission } from '@/utils' +import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout' +import Pagination from '@/Components/Pagination' +import ModalConfirm from '@/Components/ModalConfirm' +import FormModal from './FormModal' + +export default function Classification(props) { + const { data: classifications, links } = props.classifications + + const formModal = useModalState(false) + const toggle = (classification = null) => { + formModal.setData(classification) + formModal.toggle() + } + + const confirmModal = useModalState(false) + const handleDelete = (classification) => { + confirmModal.setData(classification) + confirmModal.toggle() + } + + const onDelete = () => { + const classification = confirmModal.data + if(classification != null) { + router.delete(route('classifications.destroy', classification), { + onSuccess: () => toast.success('The Data has been deleted'), + }) + } + } + + const canCreate = hasPermission('create-classification', props.auth.user) + const canUpdate = hasPermission('update-classification', props.auth.user) + const canDelete = hasPermission('delete-classification', props.auth.user) + + return ( + + +
+
+
+
+ {canCreate && ( +
toggle()} + > + Tambah +
+ )} +
+
+ + + + + + + + + + {classifications?.map((classification) => ( + + + + + + ))} + +
IdNama
{classification.id}{classification.name} + {canUpdate && ( +
+ toggle(classification) + } + > + Edit +
+ )} + {canDelete && ( +
+ handleDelete(classification) + } + > + Delete +
+ )} +
+
+ +
+
+
+ + + +
+ ) +} \ No newline at end of file diff --git a/resources/js/Pages/Document/Index.jsx b/resources/js/Pages/Document/Index.jsx index 6aa4f69..fdc0628 100644 --- a/resources/js/Pages/Document/Index.jsx +++ b/resources/js/Pages/Document/Index.jsx @@ -134,10 +134,12 @@ export default function Document(props) { + + @@ -146,15 +148,19 @@ export default function Document(props) { {docs?.map((doc) => ( + + - + @@ -73,6 +74,7 @@ export default function Types(props) { +
Perusahaan sort('type_id')}>Jenis sort('category_id')}>Ketegori No Dokumen Nama Dokumen sort('publish_date')}>Tanggal Terbit sort('due_date')}>Tanggal Berakhir Catatan
{doc.company.short} {doc.variety.name} {doc.category.name} {doc.no_doc} {doc.name} + {doc.publish_date !== null ? formatDate(doc.publish_date) : ''} + {doc.due_date !== null ? formatDate(doc.due_date) : ''} {doc.due_status} +
    diff --git a/resources/js/Pages/Type/FormModal.jsx b/resources/js/Pages/Type/FormModal.jsx index 45124d7..8acd3a9 100644 --- a/resources/js/Pages/Type/FormModal.jsx +++ b/resources/js/Pages/Type/FormModal.jsx @@ -4,9 +4,11 @@ import { toast } from 'react-toastify' export default function FormModal(props) { const { modalState } = props + const { props: { classifications } } = usePage() const { data, setData, post, put, processing, errors, reset, clearErrors } = useForm({ name: '', + classification_id: '' }) const handleOnChange = (event) => { @@ -52,6 +54,7 @@ export default function FormModal(props) { if (type !== null) { setData({ name: type?.name, + classification_id: type?.classification_id }) } }, [modalState]) @@ -90,6 +93,29 @@ export default function FormModal(props) { {errors.name}
+
+ + + +
Id NamaKlasifikasi
{type.id} {type.name}{type?.classification?.name} {canUpdate && (
group(function () { Route::post('/companies', [CompanyController::class, 'store'])->name('companies.store'); Route::put('/companies/{company}', [CompanyController::class, 'update'])->name('companies.update'); Route::delete('/companies/{company}', [CompanyController::class, 'destroy'])->name('companies.destroy'); + + Route::get('/classifications', [ClassificationController::class, 'index'])->name('classifications.index'); + Route::post('/classifications', [ClassificationController::class, 'store'])->name('classifications.store'); + Route::put('/classifications/{classification}', [ClassificationController::class, 'update'])->name('classifications.update'); + Route::delete('/classifications/{classification}', [ClassificationController::class, 'destroy'])->name('classifications.destroy'); Route::get('/types', [TypeController::class, 'index'])->name('types.index'); Route::post('/types', [TypeController::class, 'store'])->name('types.store');