ReviewOS

also looking at this

meemalabs/meema-client-php

Media model

#6
Merged glennmichael123 wants to merge media-model into main
7 files +1700 -76

Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.

composer.jsonmodified+2-1
Changes to composer.json
@@ -19,7 +19,8 @@
1919 ],
2020 "require": {
2121 "guzzlehttp/guzzle": "^7.2",
22 "vlucas/phpdotenv": "^5.3"
22 "vlucas/phpdotenv": "^5.3",
23 "illuminate/support": "^8.35"
2324 },
2425 "autoload": {
2526 "psr-4": {
composer.lockmodified+708-1
Changes to composer.lock
@@ -4,8 +4,99 @@
44 "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
55 "This file is @generated automatically"
66 ],
7 "content-hash": "81f9442b4c68ef1ee0152dda21744b84",
7 "content-hash": "0f531baa6d19f003df2c4c502f030e37",
88 "packages": [
9 {
10 "name": "doctrine/inflector",
11 "version": "2.0.3",
12 "source": {
13 "type": "git",
14 "url": "https://github.com/doctrine/inflector.git",
15 "reference": "9cf661f4eb38f7c881cac67c75ea9b00bf97b210"
16 },
17 "dist": {
18 "type": "zip",
19 "url": "https://api.github.com/repos/doctrine/inflector/zipball/9cf661f4eb38f7c881cac67c75ea9b00bf97b210",
20 "reference": "9cf661f4eb38f7c881cac67c75ea9b00bf97b210",
21 "shasum": ""
22 },
23 "require": {
24 "php": "^7.2 || ^8.0"
25 },
26 "require-dev": {
27 "doctrine/coding-standard": "^7.0",
28 "phpstan/phpstan": "^0.11",
29 "phpstan/phpstan-phpunit": "^0.11",
30 "phpstan/phpstan-strict-rules": "^0.11",
31 "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0"
32 },
33 "type": "library",
34 "extra": {
35 "branch-alias": {
36 "dev-master": "2.0.x-dev"
37 }
38 },
39 "autoload": {
40 "psr-4": {
41 "Doctrine\\Inflector\\": "lib/Doctrine/Inflector"
42 }
43 },
44 "notification-url": "https://packagist.org/downloads/",
45 "license": [
46 "MIT"
47 ],
48 "authors": [
49 {
50 "name": "Guilherme Blanco",
51 "email": "guilhermeblanco@gmail.com"
52 },
53 {
54 "name": "Roman Borschel",
55 "email": "roman@code-factory.org"
56 },
57 {
58 "name": "Benjamin Eberlei",
59 "email": "kontakt@beberlei.de"
60 },
61 {
62 "name": "Jonathan Wage",
63 "email": "jonwage@gmail.com"
64 },
65 {
66 "name": "Johannes Schmitt",
67 "email": "schmittjoh@gmail.com"
68 }
69 ],
70 "description": "PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.",
71 "homepage": "https://www.doctrine-project.org/projects/inflector.html",
72 "keywords": [
73 "inflection",
74 "inflector",
75 "lowercase",
76 "manipulation",
77 "php",
78 "plural",
79 "singular",
80 "strings",
81 "uppercase",
82 "words"
83 ],
84 "funding": [
85 {
86 "url": "https://www.doctrine-project.org/sponsorship.html",
87 "type": "custom"
88 },
89 {
90 "url": "https://www.patreon.com/phpdoctrine",
91 "type": "patreon"
92 },
93 {
94 "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finflector",
95 "type": "tidelift"
96 }
97 ],
98 "time": "2020-05-29T15:13:26+00:00"
99 },
9100 {
10101 "name": "graham-campbell/result-type",
11102 "version": "v1.0.1",
@@ -300,6 +391,295 @@
300391 },
301392 "time": "2020-09-30T07:37:11+00:00"
302393 },
394 {
395 "name": "illuminate/collections",
396 "version": "v8.35.1",
397 "source": {
398 "type": "git",
399 "url": "https://github.com/illuminate/collections.git",
400 "reference": "0a7a96520928b61df1750b4e1909588f10ae2abe"
401 },
402 "dist": {
403 "type": "zip",
404 "url": "https://api.github.com/repos/illuminate/collections/zipball/0a7a96520928b61df1750b4e1909588f10ae2abe",
405 "reference": "0a7a96520928b61df1750b4e1909588f10ae2abe",
406 "shasum": ""
407 },
408 "require": {
409 "illuminate/contracts": "^8.0",
410 "illuminate/macroable": "^8.0",
411 "php": "^7.3|^8.0"
412 },
413 "suggest": {
414 "symfony/var-dumper": "Required to use the dump method (^5.1.4)."
415 },
416 "type": "library",
417 "extra": {
418 "branch-alias": {
419 "dev-master": "8.x-dev"
420 }
421 },
422 "autoload": {
423 "psr-4": {
424 "Illuminate\\Support\\": ""
425 },
426 "files": [
427 "helpers.php"
428 ]
429 },
430 "notification-url": "https://packagist.org/downloads/",
431 "license": [
432 "MIT"
433 ],
434 "authors": [
435 {
436 "name": "Taylor Otwell",
437 "email": "taylor@laravel.com"
438 }
439 ],
440 "description": "The Illuminate Collections package.",
441 "homepage": "https://laravel.com",
442 "time": "2021-03-25T14:54:04+00:00"
443 },
444 {
445 "name": "illuminate/contracts",
446 "version": "v8.35.1",
447 "source": {
448 "type": "git",
449 "url": "https://github.com/illuminate/contracts.git",
450 "reference": "121cea1d8b8772bc7fee99c71ecf0f57c1d77b3b"
451 },
452 "dist": {
453 "type": "zip",
454 "url": "https://api.github.com/repos/illuminate/contracts/zipball/121cea1d8b8772bc7fee99c71ecf0f57c1d77b3b",
455 "reference": "121cea1d8b8772bc7fee99c71ecf0f57c1d77b3b",
456 "shasum": ""
457 },
458 "require": {
459 "php": "^7.3|^8.0",
460 "psr/container": "^1.0",
461 "psr/simple-cache": "^1.0"
462 },
463 "type": "library",
464 "extra": {
465 "branch-alias": {
466 "dev-master": "8.x-dev"
467 }
468 },
469 "autoload": {
470 "psr-4": {
471 "Illuminate\\Contracts\\": ""
472 }
473 },
474 "notification-url": "https://packagist.org/downloads/",
475 "license": [
476 "MIT"
477 ],
478 "authors": [
479 {
480 "name": "Taylor Otwell",
481 "email": "taylor@laravel.com"
482 }
483 ],
484 "description": "The Illuminate Contracts package.",
485 "homepage": "https://laravel.com",
486 "time": "2021-03-12T14:45:30+00:00"
487 },
488 {
489 "name": "illuminate/macroable",
490 "version": "v8.35.1",
491 "source": {
492 "type": "git",
493 "url": "https://github.com/illuminate/macroable.git",
494 "reference": "300aa13c086f25116b5f3cde3ca54ff5c822fb05"
495 },
496 "dist": {
497 "type": "zip",
498 "url": "https://api.github.com/repos/illuminate/macroable/zipball/300aa13c086f25116b5f3cde3ca54ff5c822fb05",
499 "reference": "300aa13c086f25116b5f3cde3ca54ff5c822fb05",
500 "shasum": ""
501 },
502 "require": {
503 "php": "^7.3|^8.0"
504 },
505 "type": "library",
506 "extra": {
507 "branch-alias": {
508 "dev-master": "8.x-dev"
509 }
510 },
511 "autoload": {
512 "psr-4": {
513 "Illuminate\\Support\\": ""
514 }
515 },
516 "notification-url": "https://packagist.org/downloads/",
517 "license": [
518 "MIT"
519 ],
520 "authors": [
521 {
522 "name": "Taylor Otwell",
523 "email": "taylor@laravel.com"
524 }
525 ],
526 "description": "The Illuminate Macroable package.",
527 "homepage": "https://laravel.com",
528 "time": "2020-10-27T15:20:30+00:00"
529 },
530 {
531 "name": "illuminate/support",
532 "version": "v8.35.1",
533 "source": {
534 "type": "git",
535 "url": "https://github.com/illuminate/support.git",
536 "reference": "8eee1bc181c87cfdac32b4d876ab44da9894771c"
537 },
538 "dist": {
539 "type": "zip",
540 "url": "https://api.github.com/repos/illuminate/support/zipball/8eee1bc181c87cfdac32b4d876ab44da9894771c",
541 "reference": "8eee1bc181c87cfdac32b4d876ab44da9894771c",
542 "shasum": ""
543 },
544 "require": {
545 "doctrine/inflector": "^1.4|^2.0",
546 "ext-json": "*",
547 "ext-mbstring": "*",
548 "illuminate/collections": "^8.0",
549 "illuminate/contracts": "^8.0",
550 "illuminate/macroable": "^8.0",
551 "nesbot/carbon": "^2.31",
552 "php": "^7.3|^8.0",
553 "voku/portable-ascii": "^1.4.8"
554 },
555 "conflict": {
556 "tightenco/collect": "<5.5.33"
557 },
558 "suggest": {
559 "illuminate/filesystem": "Required to use the composer class (^8.0).",
560 "league/commonmark": "Required to use Str::markdown() and Stringable::markdown() (^1.3).",
561 "ramsey/uuid": "Required to use Str::uuid() (^4.0).",
562 "symfony/process": "Required to use the composer class (^5.1.4).",
563 "symfony/var-dumper": "Required to use the dd function (^5.1.4).",
564 "vlucas/phpdotenv": "Required to use the Env class and env helper (^5.2)."
565 },
566 "type": "library",
567 "extra": {
568 "branch-alias": {
569 "dev-master": "8.x-dev"
570 }
571 },
572 "autoload": {
573 "psr-4": {
574 "Illuminate\\Support\\": ""
575 },
576 "files": [
577 "helpers.php"
578 ]
579 },
580 "notification-url": "https://packagist.org/downloads/",
581 "license": [
582 "MIT"
583 ],
584 "authors": [
585 {
586 "name": "Taylor Otwell",
587 "email": "taylor@laravel.com"
588 }
589 ],
590 "description": "The Illuminate Support package.",
591 "homepage": "https://laravel.com",
592 "time": "2021-03-30T13:39:44+00:00"
593 },
594 {
595 "name": "nesbot/carbon",
596 "version": "2.46.0",
597 "source": {
598 "type": "git",
599 "url": "https://github.com/briannesbitt/Carbon.git",
600 "reference": "2fd2c4a77d58a4e95234c8a61c5df1f157a91bf4"
601 },
602 "dist": {
603 "type": "zip",
604 "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/2fd2c4a77d58a4e95234c8a61c5df1f157a91bf4",
605 "reference": "2fd2c4a77d58a4e95234c8a61c5df1f157a91bf4",
606 "shasum": ""
607 },
608 "require": {
609 "ext-json": "*",
610 "php": "^7.1.8 || ^8.0",
611 "symfony/polyfill-mbstring": "^1.0",
612 "symfony/translation": "^3.4 || ^4.0 || ^5.0"
613 },
614 "require-dev": {
615 "doctrine/orm": "^2.7",
616 "friendsofphp/php-cs-fixer": "^2.14 || ^3.0",
617 "kylekatarnls/multi-tester": "^2.0",
618 "phpmd/phpmd": "^2.9",
619 "phpstan/extension-installer": "^1.0",
620 "phpstan/phpstan": "^0.12.54",
621 "phpunit/phpunit": "^7.5.20 || ^8.5.14",
622 "squizlabs/php_codesniffer": "^3.4"
623 },
624 "bin": [
625 "bin/carbon"
626 ],
627 "type": "library",
628 "extra": {
629 "branch-alias": {
630 "dev-master": "2.x-dev",
631 "dev-3.x": "3.x-dev"
632 },
633 "laravel": {
634 "providers": [
635 "Carbon\\Laravel\\ServiceProvider"
636 ]
637 },
638 "phpstan": {
639 "includes": [
640 "extension.neon"
641 ]
642 }
643 },
644 "autoload": {
645 "psr-4": {
646 "Carbon\\": "src/Carbon/"
647 }
648 },
649 "notification-url": "https://packagist.org/downloads/",
650 "license": [
651 "MIT"
652 ],
653 "authors": [
654 {
655 "name": "Brian Nesbitt",
656 "email": "brian@nesbot.com",
657 "homepage": "http://nesbot.com"
658 },
659 {
660 "name": "kylekatarnls",
661 "homepage": "http://github.com/kylekatarnls"
662 }
663 ],
664 "description": "An API extension for DateTime that supports 281 different languages.",
665 "homepage": "http://carbon.nesbot.com",
666 "keywords": [
667 "date",
668 "datetime",
669 "time"
670 ],
671 "funding": [
672 {
673 "url": "https://opencollective.com/Carbon",
674 "type": "open_collective"
675 },
676 {
677 "url": "https://tidelift.com/funding/github/packagist/nesbot/carbon",
678 "type": "tidelift"
679 }
680 ],
681 "time": "2021-02-24T17:30:44+00:00"
682 },
303683 {
304684 "name": "phpoption/phpoption",
305685 "version": "1.7.5",
@@ -365,6 +745,50 @@
365745 ],
366746 "time": "2020-07-20T17:29:33+00:00"
367747 },
748 {
749 "name": "psr/container",
750 "version": "1.1.1",
751 "source": {
752 "type": "git",
753 "url": "https://github.com/php-fig/container.git",
754 "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf"
755 },
756 "dist": {
757 "type": "zip",
758 "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf",
759 "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf",
760 "shasum": ""
761 },
762 "require": {
763 "php": ">=7.2.0"
764 },
765 "type": "library",
766 "autoload": {
767 "psr-4": {
768 "Psr\\Container\\": "src/"
769 }
770 },
771 "notification-url": "https://packagist.org/downloads/",
772 "license": [
773 "MIT"
774 ],
775 "authors": [
776 {
777 "name": "PHP-FIG",
778 "homepage": "https://www.php-fig.org/"
779 }
780 ],
781 "description": "Common Container Interface (PHP FIG PSR-11)",
782 "homepage": "https://github.com/php-fig/container",
783 "keywords": [
784 "PSR-11",
785 "container",
786 "container-interface",
787 "container-interop",
788 "psr"
789 ],
790 "time": "2021-03-05T17:36:06+00:00"
791 },
368792 {
369793 "name": "psr/http-client",
370794 "version": "1.0.1",
@@ -470,6 +894,54 @@
470894 },
471895 "time": "2016-08-06T14:39:51+00:00"
472896 },
897 {
898 "name": "psr/simple-cache",
899 "version": "1.0.1",
900 "source": {
901 "type": "git",
902 "url": "https://github.com/php-fig/simple-cache.git",
903 "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
904 },
905 "dist": {
906 "type": "zip",
907 "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
908 "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
909 "shasum": ""
910 },
911 "require": {
912 "php": ">=5.3.0"
913 },
914 "type": "library",
915 "extra": {
916 "branch-alias": {
917 "dev-master": "1.0.x-dev"
918 }
919 },
920 "autoload": {
921 "psr-4": {
922 "Psr\\SimpleCache\\": "src/"
923 }
924 },
925 "notification-url": "https://packagist.org/downloads/",
926 "license": [
927 "MIT"
928 ],
929 "authors": [
930 {
931 "name": "PHP-FIG",
932 "homepage": "http://www.php-fig.org/"
933 }
934 ],
935 "description": "Common interfaces for simple caching",
936 "keywords": [
937 "cache",
938 "caching",
939 "psr",
940 "psr-16",
941 "simple-cache"
942 ],
943 "time": "2017-10-23T01:57:42+00:00"
944 },
473945 {
474946 "name": "ralouphie/getallheaders",
475947 "version": "3.0.3",
@@ -747,6 +1219,171 @@
7471219 ],
7481220 "time": "2021-01-07T16:49:33+00:00"
7491221 },
1222 {
1223 "name": "symfony/translation",
1224 "version": "v5.2.6",
1225 "source": {
1226 "type": "git",
1227 "url": "https://github.com/symfony/translation.git",
1228 "reference": "2cc7f45d96db9adfcf89adf4401d9dfed509f4e1"
1229 },
1230 "dist": {
1231 "type": "zip",
1232 "url": "https://api.github.com/repos/symfony/translation/zipball/2cc7f45d96db9adfcf89adf4401d9dfed509f4e1",
1233 "reference": "2cc7f45d96db9adfcf89adf4401d9dfed509f4e1",
1234 "shasum": ""
1235 },
1236 "require": {
1237 "php": ">=7.2.5",
1238 "symfony/polyfill-mbstring": "~1.0",
1239 "symfony/polyfill-php80": "^1.15",
1240 "symfony/translation-contracts": "^2.3"
1241 },
1242 "conflict": {
1243 "symfony/config": "<4.4",
1244 "symfony/dependency-injection": "<5.0",
1245 "symfony/http-kernel": "<5.0",
1246 "symfony/twig-bundle": "<5.0",
1247 "symfony/yaml": "<4.4"
1248 },
1249 "provide": {
1250 "symfony/translation-implementation": "2.3"
1251 },
1252 "require-dev": {
1253 "psr/log": "~1.0",
1254 "symfony/config": "^4.4|^5.0",
1255 "symfony/console": "^4.4|^5.0",
1256 "symfony/dependency-injection": "^5.0",
1257 "symfony/finder": "^4.4|^5.0",
1258 "symfony/http-kernel": "^5.0",
1259 "symfony/intl": "^4.4|^5.0",
1260 "symfony/service-contracts": "^1.1.2|^2",
1261 "symfony/yaml": "^4.4|^5.0"
1262 },
1263 "suggest": {
1264 "psr/log-implementation": "To use logging capability in translator",
1265 "symfony/config": "",
1266 "symfony/yaml": ""
1267 },
1268 "type": "library",
1269 "autoload": {
1270 "files": [
1271 "Resources/functions.php"
1272 ],
1273 "psr-4": {
1274 "Symfony\\Component\\Translation\\": ""
1275 },
1276 "exclude-from-classmap": [
1277 "/Tests/"
1278 ]
1279 },
1280 "notification-url": "https://packagist.org/downloads/",
1281 "license": [
1282 "MIT"
1283 ],
1284 "authors": [
1285 {
1286 "name": "Fabien Potencier",
1287 "email": "fabien@symfony.com"
1288 },
1289 {
1290 "name": "Symfony Community",
1291 "homepage": "https://symfony.com/contributors"
1292 }
1293 ],
1294 "description": "Provides tools to internationalize your application",
1295 "homepage": "https://symfony.com",
1296 "funding": [
1297 {
1298 "url": "https://symfony.com/sponsor",
1299 "type": "custom"
1300 },
1301 {
1302 "url": "https://github.com/fabpot",
1303 "type": "github"
1304 },
1305 {
1306 "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
1307 "type": "tidelift"
1308 }
1309 ],
1310 "time": "2021-03-23T19:33:48+00:00"
1311 },
1312 {
1313 "name": "symfony/translation-contracts",
1314 "version": "v2.3.0",
1315 "source": {
1316 "type": "git",
1317 "url": "https://github.com/symfony/translation-contracts.git",
1318 "reference": "e2eaa60b558f26a4b0354e1bbb25636efaaad105"
1319 },
1320 "dist": {
1321 "type": "zip",
1322 "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/e2eaa60b558f26a4b0354e1bbb25636efaaad105",
1323 "reference": "e2eaa60b558f26a4b0354e1bbb25636efaaad105",
1324 "shasum": ""
1325 },
1326 "require": {
1327 "php": ">=7.2.5"
1328 },
1329 "suggest": {
1330 "symfony/translation-implementation": ""
1331 },
1332 "type": "library",
1333 "extra": {
1334 "branch-alias": {
1335 "dev-master": "2.3-dev"
1336 },
1337 "thanks": {
1338 "name": "symfony/contracts",
1339 "url": "https://github.com/symfony/contracts"
1340 }
1341 },
1342 "autoload": {
1343 "psr-4": {
1344 "Symfony\\Contracts\\Translation\\": ""
1345 }
1346 },
1347 "notification-url": "https://packagist.org/downloads/",
1348 "license": [
1349 "MIT"
1350 ],
1351 "authors": [
1352 {
1353 "name": "Nicolas Grekas",
1354 "email": "p@tchwork.com"
1355 },
1356 {
1357 "name": "Symfony Community",
1358 "homepage": "https://symfony.com/contributors"
1359 }
1360 ],
1361 "description": "Generic abstractions related to translation",
1362 "homepage": "https://symfony.com",
1363 "keywords": [
1364 "abstractions",
1365 "contracts",
1366 "decoupling",
1367 "interfaces",
1368 "interoperability",
1369 "standards"
1370 ],
1371 "funding": [
1372 {
1373 "url": "https://symfony.com/sponsor",
1374 "type": "custom"
1375 },
1376 {
1377 "url": "https://github.com/fabpot",
1378 "type": "github"
1379 },
1380 {
1381 "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
1382 "type": "tidelift"
1383 }
1384 ],
1385 "time": "2020-09-28T13:05:58+00:00"
1386 },
7501387 {
7511388 "name": "vlucas/phpdotenv",
7521389 "version": "v5.3.0",
@@ -822,6 +1459,76 @@
8221459 }
8231460 ],
8241461 "time": "2021-01-20T15:23:13+00:00"
1462 },
1463 {
1464 "name": "voku/portable-ascii",
1465 "version": "1.5.6",
1466 "source": {
1467 "type": "git",
1468 "url": "https://github.com/voku/portable-ascii.git",
1469 "reference": "80953678b19901e5165c56752d087fc11526017c"
1470 },
1471 "dist": {
1472 "type": "zip",
1473 "url": "https://api.github.com/repos/voku/portable-ascii/zipball/80953678b19901e5165c56752d087fc11526017c",
1474 "reference": "80953678b19901e5165c56752d087fc11526017c",
1475 "shasum": ""
1476 },
1477 "require": {
1478 "php": ">=7.0.0"
1479 },
1480 "require-dev": {
1481 "phpunit/phpunit": "~6.0 || ~7.0 || ~9.0"
1482 },
1483 "suggest": {
1484 "ext-intl": "Use Intl for transliterator_transliterate() support"
1485 },
1486 "type": "library",
1487 "autoload": {
1488 "psr-4": {
1489 "voku\\": "src/voku/"
1490 }
1491 },
1492 "notification-url": "https://packagist.org/downloads/",
1493 "license": [
1494 "MIT"
1495 ],
1496 "authors": [
1497 {
1498 "name": "Lars Moelleken",
1499 "homepage": "http://www.moelleken.org/"
1500 }
1501 ],
1502 "description": "Portable ASCII library - performance optimized (ascii) string functions for php.",
1503 "homepage": "https://github.com/voku/portable-ascii",
1504 "keywords": [
1505 "ascii",
1506 "clean",
1507 "php"
1508 ],
1509 "funding": [
1510 {
1511 "url": "https://www.paypal.me/moelleken",
1512 "type": "custom"
1513 },
1514 {
1515 "url": "https://github.com/voku",
1516 "type": "github"
1517 },
1518 {
1519 "url": "https://opencollective.com/portable-ascii",
1520 "type": "open_collective"
1521 },
1522 {
1523 "url": "https://www.patreon.com/voku",
1524 "type": "patreon"
1525 },
1526 {
1527 "url": "https://tidelift.com/funding/github/packagist/voku/portable-ascii",
1528 "type": "tidelift"
1529 }
1530 ],
1531 "time": "2020-11-12T00:07:28+00:00"
8251532 }
8261533 ],
8271534 "packages-dev": [],
src/Models/Folder.phpmodified+21-9
Changes to src/Models/Folder.php
@@ -21,9 +21,9 @@ class Folder
2121 protected $id;
2222
2323 /**
24 * @var int
24 * @var object
2525 */
26 protected $mediaId;
26 protected $model;
2727
2828 /**
2929 * @var array
@@ -35,11 +35,9 @@ class Folder
3535 *
3636 * @param Meema\MeemaApi\Client $client
3737 */
38 public function __construct(Client $client, $mediaId = null)
38 public function __construct(Client $client)
3939 {
4040 $this->client = $client;
41
42 $this->mediaId = $mediaId;
4341 }
4442
4543 /**
@@ -98,10 +96,10 @@ class Folder
9896 {
9997 $name = is_array($name) ? $name : compact('name');
10098
101 if ($this->mediaId) {
99 if ($this->model) {
102100 $folderName = ['folder_name' => $name['name']];
103101
104 return $this->addFolderToMedia($this->mediaId, $folderName);
102 return $this->addFolderToMedia($this->model->getId(), $folderName);
105103 }
106104
107105 return $this->client->request('POST', "folders/{$this->client->getAccessKey()}", $name);
@@ -133,8 +131,8 @@ class Folder
133131 */
134132 public function delete($id = null)
135133 {
136 if ($this->mediaId) {
137 return $this->deleteFolderFromMedia($this->mediaId, $id);
134 if ($this->model) {
135 return $this->deleteFolderFromMedia($this->model->getId(), $id);
138136 }
139137
140138 $id = $this->id ?? $id;
@@ -219,4 +217,18 @@ class Folder
219217 {
220218 return $this->client->request('DELETE', "media/{$mediaId}/folders/{$folderId}");
221219 }
220
221 /**
222 * Initialize media model
223 *
224 * @param Meema\MeemaApi\Models\Media $media
225 *
226 * @return void
227 */
228 public function setMedia($media): self
229 {
230 $this->model = $media;
231
232 return $this;
233 }
222234}
src/Models/Media.phpmodified+13-25
Changes to src/Models/Media.php
@@ -4,12 +4,9 @@ namespace Meema\MeemaApi\Models;
44
55use Meema\MeemaApi\Client;
66use Meema\MeemaApi\Response\Response;
7use Meema\MeemaApi\Traits\SerializesResponse;
87
98class Media
109{
11 use SerializesResponse;
12
1310 /**
1411 * @var Meema\MeemaApi\Client
1512 */
@@ -83,7 +80,6 @@ class Media
8380 {
8481 $response = $this->client->request('GET', "folders/${id}");
8582
86 $this->content = $response;
8783 $this->id = $response['data']['id'];
8884
8985 return new Response($this, $response);
@@ -111,10 +107,8 @@ class Media
111107 *
112108 * @return array
113109 */
114 public function update($name, $id = null): array
110 public function update($id, $name): array
115111 {
116 $id = $this->id ?? $id;
117
118112 $name = is_array($name) ? $name : compact('name');
119113
120114 return $this->client->request('PATCH', "media/{$id}/file-name", $name);
@@ -129,8 +123,6 @@ class Media
129123 */
130124 public function delete($id = null)
131125 {
132 $id = $this->id ?? $id;
133
134126 return $this->client->request('DELETE', "media/{$id}", ['media_id' => $id]);
135127 }
136128
@@ -143,8 +135,6 @@ class Media
143135 */
144136 public function archive($id = null): array
145137 {
146 $id = $this->id ?? $id;
147
148138 return $this->client->request('POST', "media/{$id}/archive");
149139 }
150140
@@ -155,10 +145,8 @@ class Media
155145 *
156146 * @return array
157147 */
158 public function unarchive($id = null): array
148 public function unarchive($id): array
159149 {
160 $id = $this->id ?? $id;
161
162150 return $this->client->request('POST', "media/{$id}/unarchive");
163151 }
164152
@@ -169,10 +157,8 @@ class Media
169157 *
170158 * @return array
171159 */
172 public function makePrivate($id = null): array
160 public function makePrivate($id): array
173161 {
174 $id = $this->id ?? $id;
175
176162 return $this->client->request('PATCH', "media/{$id}/make-private");
177163 }
178164
@@ -183,10 +169,8 @@ class Media
183169 *
184170 * @return array
185171 */
186 public function makePublic($id = null): array
172 public function makePublic($id): array
187173 {
188 $id = $this->id ?? $id;
189
190174 return $this->client->request('PATCH', "media/{$id}/make-public");
191175 }
192176
@@ -197,10 +181,8 @@ class Media
197181 *
198182 * @return array
199183 */
200 public function duplicate($id = null): array
184 public function duplicate($id): array
201185 {
202 $id = $this->id ?? $id;
203
204186 return $this->client->request('POST', "media/{$id}/duplicate");
205187 }
206188
@@ -209,11 +191,12 @@ class Media
209191 *
210192 * @return Meema\MeemaApi\Models\Folder
211193 */
212 public function folders(): Folder
194 public function folders()
213195 {
214196 $client = new Client($this->client->getAccessKey());
215197
216 return new Folder($client, $this->id);
198 return (new Folder($client))
199 ->setMedia($this);
217200 }
218201
219202 /**
@@ -227,4 +210,9 @@ class Media
227210 {
228211 return $this->client->request('GET', "folders/{$id}/media");
229212 }
213
214 public function getId()
215 {
216 return $this->id;
217 }
230218}
src/Response/Response.phpmodified+60-2
Changes to src/Response/Response.php
@@ -2,17 +2,27 @@
22
33namespace Meema\MeemaApi\Response;
44
5use Illuminate\Support\Arr;
56use Meema\MeemaApi\Traits\ForwardsCalls;
67
78class Response
89{
910 use ForwardsCalls;
1011
12 /**
13 * @var \Meema\MeemaApi\Client
14 */
1115 protected $api;
1216
13 public function __construct($api)
17 /**
18 * @var array
19 */
20 protected $content;
21
22 public function __construct($api, $content)
1423 {
1524 $this->api = $api;
25 $this->content = $content;
1626 }
1727
1828 /**
@@ -20,10 +30,58 @@ class Response
2030 *
2131 * @param string $method
2232 * @param array $parameters
33 *
2334 * @return mixed
2435 */
2536 public function __call($method, $parameters)
2637 {
27 return $this->forwardCallTo($this->api, $method, $parameters);
38 return $this->forwardCallTo($this->api, $method, array_merge(
39 Arr::wrap($this->getKey()), $parameters
40 ));
41 }
42
43 /**
44 * Get the primary key for the model.
45 *
46 * @return string
47 */
48 public function getKeyName()
49 {
50 return 'id';
51 }
52
53 /**
54 * Get the value of the response primary key.
55 *
56 * @return mixed
57 */
58 public function getKey()
59 {
60 return $this->getData($this->getKeyName());
61 }
62
63 /**
64 * Get data.
65 *
66 * @return array
67 */
68 public function getData($key)
69 {
70 return $this->getContent('data'.($key ? '.'.$key : ''));
71 }
72
73 /**
74 * Get response content.
75 *
76 * @param mixed $key
77 * @return array
78 */
79 public function getContent($key = null)
80 {
81 if ($key) {
82 return Arr::get($this->content, $key);
83 }
84
85 return $this->content;
2886 }
2987}