Browse Source

Merge branch 'project-file-deletion'

Closes #35
pull/37/head
Nafies Luthfi 7 years ago
parent
commit
8c2e21da2b
  1. 23
      app/Http/Controllers/Projects/FilesController.php
  2. 301
      composer.lock
  3. 1
      phpunit.xml
  4. 20
      resources/views/projects/files.blade.php
  5. 1
      routes/web/projects.php
  6. 39
      tests/Feature/Projects/UploadFilesTest.php

23
app/Http/Controllers/Projects/FilesController.php

@ -2,6 +2,7 @@
namespace App\Http\Controllers\Projects;
use Storage;
use File as FileSystem;
use Illuminate\Http\Request;
use App\Entities\Projects\File;
@ -70,7 +71,7 @@ class FilesController extends Controller
return response()->download(storage_path('app/public/files/'.$file->filename), $file->title.'.'.$extension);
}
flash(trans('file.not_found'), 'danger');
flash(__('file.not_found'), 'danger');
if (\URL::previous() != \URL::current()) {
return back();
@ -85,7 +86,17 @@ class FilesController extends Controller
$file->description = $request->get('description');
$file->save();
flash(trans('file.updated'), 'success');
flash(__('file.updated'), 'success');
return redirect()->route($file->fileable_type.'.files', $file->fileable_id);
}
public function destroy(Request $request, File $file)
{
Storage::delete('public/files/'.$file->filename);
$file->delete();
flash(__('file.deleted'), 'warning');
return redirect()->route($file->fileable_type.'.files', $file->fileable_id);
}
@ -101,13 +112,7 @@ class FilesController extends Controller
$fileData['title'] = $data['title'];
$fileData['description'] = $data['description'];
\DB::beginTransaction();
// dd(is_dir(storage_path('app/public/files')));
if (env('APP_ENV') == 'testing') {
$file->store('public/files', 'avatar');
} else {
$file->store('public/files');
}
// $file->move(storage_path('app/public/files'));
$file->store('public/files');
$file = File::create($fileData);
\DB::commit();

301
composer.lock

@ -8,16 +8,16 @@
"packages": [
{
"name": "backup-manager/backup-manager",
"version": "1.2.1",
"version": "1.3.0",
"source": {
"type": "git",
"url": "https://github.com/backup-manager/backup-manager.git",
"reference": "4b3d74bb929aebc2df0f39f1032e0ca5e0948247"
"reference": "2176c335e0a3a3f65da4f3966a5336856206a86b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/backup-manager/backup-manager/zipball/4b3d74bb929aebc2df0f39f1032e0ca5e0948247",
"reference": "4b3d74bb929aebc2df0f39f1032e0ca5e0948247",
"url": "https://api.github.com/repos/backup-manager/backup-manager/zipball/2176c335e0a3a3f65da4f3966a5336856206a86b",
"reference": "2176c335e0a3a3f65da4f3966a5336856206a86b",
"shasum": ""
},
"require": {
@ -32,17 +32,20 @@
"league/flysystem-dropbox": "~1.0",
"league/flysystem-rackspace": "~1.0",
"league/flysystem-sftp": "~1.0",
"mhetreramesh/flysystem-backblaze": "~1.0",
"mockery/mockery": "~0.9",
"phpspec/phpspec": "~2.1",
"satooshi/php-coveralls": "~0.6",
"srmklive/flysystem-dropbox-v2": "~1.0"
"srmklive/flysystem-dropbox-v2": "~1.0",
"superbalist/flysystem-google-storage": "^7.0"
},
"suggest": {
"league/flysystem-aws-s3-v2": "GoogleCS adapter support.",
"league/flysystem-aws-s3-v3": "AwsS3 adapter support.",
"league/flysystem-aws-s3-v3": "AWS S3 adapter support.",
"league/flysystem-rackspace": "Rackspace adapter support.",
"league/flysystem-sftp": "Sftp adapter support.",
"srmklive/flysystem-dropbox-v2": "Dropbox API v2 adapter support."
"league/flysystem-sftp": "SFTP adapter support.",
"mhetreramesh/flysystem-backblaze": "B2 adapter support.",
"srmklive/flysystem-dropbox-v2": "Dropbox API v2 adapter support.",
"superbalist/flysystem-google-storage": "Google Cloud Storage adapter support."
},
"type": "library",
"extra": {
@ -72,7 +75,7 @@
}
],
"description": "A framework agnostic database backup manager with user-definable procedures and support for S3, Dropbox, FTP, SFTP, and more with drivers for popular frameworks.",
"time": "2018-09-23T09:14:37+00:00"
"time": "2018-10-16T19:36:05+00:00"
},
{
"name": "backup-manager/laravel",
@ -410,16 +413,16 @@
},
{
"name": "fideloper/proxy",
"version": "4.0.0",
"version": "4.1.0",
"source": {
"type": "git",
"url": "https://github.com/fideloper/TrustedProxy.git",
"reference": "cf8a0ca4b85659b9557e206c90110a6a4dba980a"
"reference": "177c79a2d1f9970f89ee2fb4c12b429af38b6dfb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fideloper/TrustedProxy/zipball/cf8a0ca4b85659b9557e206c90110a6a4dba980a",
"reference": "cf8a0ca4b85659b9557e206c90110a6a4dba980a",
"url": "https://api.github.com/repos/fideloper/TrustedProxy/zipball/177c79a2d1f9970f89ee2fb4c12b429af38b6dfb",
"reference": "177c79a2d1f9970f89ee2fb4c12b429af38b6dfb",
"shasum": ""
},
"require": {
@ -460,7 +463,7 @@
"proxy",
"trusted proxy"
],
"time": "2018-02-07T20:20:57+00:00"
"time": "2019-01-10T14:06:47+00:00"
},
{
"name": "guzzlehttp/guzzle",
@ -693,16 +696,16 @@
},
{
"name": "laravel/framework",
"version": "v5.7.19",
"version": "v5.7.26",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "5c1d1ec7e8563ea31826fd5eb3f6791acf01160c"
"reference": "ca3bc9769969e8af3bd9878a3e0242051c74dae4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/5c1d1ec7e8563ea31826fd5eb3f6791acf01160c",
"reference": "5c1d1ec7e8563ea31826fd5eb3f6791acf01160c",
"url": "https://api.github.com/repos/laravel/framework/zipball/ca3bc9769969e8af3bd9878a3e0242051c74dae4",
"reference": "ca3bc9769969e8af3bd9878a3e0242051c74dae4",
"shasum": ""
},
"require": {
@ -776,7 +779,7 @@
"moontoast/math": "^1.1",
"orchestra/testbench-core": "3.7.*",
"pda/pheanstalk": "^3.0",
"phpunit/phpunit": "^7.0",
"phpunit/phpunit": "^7.5",
"predis/predis": "^1.1.1",
"symfony/css-selector": "^4.1",
"symfony/dom-crawler": "^4.1",
@ -835,7 +838,7 @@
"framework",
"laravel"
],
"time": "2018-12-18T14:00:38+00:00"
"time": "2019-02-12T14:52:21+00:00"
},
{
"name": "laravel/nexmo-notification-channel",
@ -1079,16 +1082,16 @@
},
{
"name": "league/flysystem",
"version": "1.0.49",
"version": "1.0.50",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
"reference": "a63cc83d8a931b271be45148fa39ba7156782ffd"
"reference": "dab4e7624efa543a943be978008f439c333f2249"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/a63cc83d8a931b271be45148fa39ba7156782ffd",
"reference": "a63cc83d8a931b271be45148fa39ba7156782ffd",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/dab4e7624efa543a943be978008f439c333f2249",
"reference": "dab4e7624efa543a943be978008f439c333f2249",
"shasum": ""
},
"require": {
@ -1159,7 +1162,7 @@
"sftp",
"storage"
],
"time": "2018-11-23T23:41:29+00:00"
"time": "2019-02-01T08:50:36+00:00"
},
{
"name": "league/fractal",
@ -1415,16 +1418,16 @@
},
{
"name": "nexmo/client",
"version": "1.6.0",
"version": "1.6.2",
"source": {
"type": "git",
"url": "https://github.com/Nexmo/nexmo-php.git",
"reference": "01809cc1e17a5af275913c49bb5d444eb6cc06d4"
"reference": "2f79f67f24225ea627ee14578e98c96276cdd4c5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Nexmo/nexmo-php/zipball/01809cc1e17a5af275913c49bb5d444eb6cc06d4",
"reference": "01809cc1e17a5af275913c49bb5d444eb6cc06d4",
"url": "https://api.github.com/repos/Nexmo/nexmo-php/zipball/2f79f67f24225ea627ee14578e98c96276cdd4c5",
"reference": "2f79f67f24225ea627ee14578e98c96276cdd4c5",
"shasum": ""
},
"require": {
@ -1459,20 +1462,20 @@
}
],
"description": "PHP Client for using Nexmo's API.",
"time": "2018-12-17T10:47:50+00:00"
"time": "2019-02-07T11:14:34+00:00"
},
{
"name": "opis/closure",
"version": "3.1.3",
"version": "3.1.5",
"source": {
"type": "git",
"url": "https://github.com/opis/closure.git",
"reference": "5e9095ce871a425ab87a854b285b7766de38a7d9"
"reference": "41f5da65d75cf473e5ee582df8fc7f2c733ce9d6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/opis/closure/zipball/5e9095ce871a425ab87a854b285b7766de38a7d9",
"reference": "5e9095ce871a425ab87a854b285b7766de38a7d9",
"url": "https://api.github.com/repos/opis/closure/zipball/41f5da65d75cf473e5ee582df8fc7f2c733ce9d6",
"reference": "41f5da65d75cf473e5ee582df8fc7f2c733ce9d6",
"shasum": ""
},
"require": {
@ -1520,7 +1523,7 @@
"serialization",
"serialize"
],
"time": "2019-01-06T22:07:38+00:00"
"time": "2019-01-14T14:45:33+00:00"
},
{
"name": "paragonie/random_compat",
@ -2158,16 +2161,16 @@
},
{
"name": "spatie/laravel-fractal",
"version": "5.4.2",
"version": "5.4.3",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-fractal.git",
"reference": "2931881cac3155ceb798f2fd1e55bd152576682b"
"reference": "514663b6b331a6c62ab6321cdf68d790a706e082"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-fractal/zipball/2931881cac3155ceb798f2fd1e55bd152576682b",
"reference": "2931881cac3155ceb798f2fd1e55bd152576682b",
"url": "https://api.github.com/repos/spatie/laravel-fractal/zipball/514663b6b331a6c62ab6321cdf68d790a706e082",
"reference": "514663b6b331a6c62ab6321cdf68d790a706e082",
"shasum": ""
},
"require": {
@ -2178,7 +2181,8 @@
},
"require-dev": {
"orchestra/testbench": "~3.5.0|~3.6.0|~3.7.0",
"phpunit/phpunit": "^6.2|^7.0"
"phpunit/phpunit": "^6.2|^7.0",
"scrutinizer/ocular": "^1.5"
},
"type": "library",
"extra": {
@ -2222,7 +2226,7 @@
"spatie",
"transform"
],
"time": "2018-09-28T16:17:34+00:00"
"time": "2019-01-16T12:38:34+00:00"
},
{
"name": "swiftmailer/swiftmailer",
@ -2285,16 +2289,16 @@
},
{
"name": "symfony/console",
"version": "v4.2.2",
"version": "v4.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "b0a03c1bb0fcbe288629956cf2f1dd3f1dc97522"
"reference": "1f0ad51dfde4da8a6070f06adc58b4e37cbb37a4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/b0a03c1bb0fcbe288629956cf2f1dd3f1dc97522",
"reference": "b0a03c1bb0fcbe288629956cf2f1dd3f1dc97522",
"url": "https://api.github.com/repos/symfony/console/zipball/1f0ad51dfde4da8a6070f06adc58b4e37cbb37a4",
"reference": "1f0ad51dfde4da8a6070f06adc58b4e37cbb37a4",
"shasum": ""
},
"require": {
@ -2306,6 +2310,9 @@
"symfony/dependency-injection": "<3.4",
"symfony/process": "<3.3"
},
"provide": {
"psr/log-implementation": "1.0"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "~3.4|~4.0",
@ -2315,7 +2322,7 @@
"symfony/process": "~3.4|~4.0"
},
"suggest": {
"psr/log-implementation": "For using the console logger",
"psr/log": "For using the console logger",
"symfony/event-dispatcher": "",
"symfony/lock": "",
"symfony/process": ""
@ -2350,7 +2357,7 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2019-01-04T15:13:53+00:00"
"time": "2019-01-25T14:35:16+00:00"
},
{
"name": "symfony/contracts",
@ -2422,16 +2429,16 @@
},
{
"name": "symfony/css-selector",
"version": "v4.2.2",
"version": "v4.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
"reference": "76dac1dbe2830213e95892c7c2ec1edd74113ea4"
"reference": "48eddf66950fa57996e1be4a55916d65c10c604a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/76dac1dbe2830213e95892c7c2ec1edd74113ea4",
"reference": "76dac1dbe2830213e95892c7c2ec1edd74113ea4",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/48eddf66950fa57996e1be4a55916d65c10c604a",
"reference": "48eddf66950fa57996e1be4a55916d65c10c604a",
"shasum": ""
},
"require": {
@ -2471,20 +2478,20 @@
],
"description": "Symfony CssSelector Component",
"homepage": "https://symfony.com",
"time": "2019-01-03T09:07:35+00:00"
"time": "2019-01-16T20:31:39+00:00"
},
{
"name": "symfony/debug",
"version": "v4.2.2",
"version": "v4.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
"reference": "64cb33c81e37d19b7715d4a6a4d49c1c382066dd"
"reference": "cf9b2e33f757deb884ce474e06d2647c1c769b65"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/64cb33c81e37d19b7715d4a6a4d49c1c382066dd",
"reference": "64cb33c81e37d19b7715d4a6a4d49c1c382066dd",
"url": "https://api.github.com/repos/symfony/debug/zipball/cf9b2e33f757deb884ce474e06d2647c1c769b65",
"reference": "cf9b2e33f757deb884ce474e06d2647c1c769b65",
"shasum": ""
},
"require": {
@ -2527,20 +2534,20 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2019-01-03T09:07:35+00:00"
"time": "2019-01-25T14:35:16+00:00"
},
{
"name": "symfony/event-dispatcher",
"version": "v4.2.2",
"version": "v4.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "887de6d34c86cf0cb6cbf910afb170cdb743cb5e"
"reference": "bd09ad265cd50b2b9d09d65ce6aba2d29bc81fe1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/887de6d34c86cf0cb6cbf910afb170cdb743cb5e",
"reference": "887de6d34c86cf0cb6cbf910afb170cdb743cb5e",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/bd09ad265cd50b2b9d09d65ce6aba2d29bc81fe1",
"reference": "bd09ad265cd50b2b9d09d65ce6aba2d29bc81fe1",
"shasum": ""
},
"require": {
@ -2591,20 +2598,20 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
"time": "2019-01-05T16:37:49+00:00"
"time": "2019-01-16T20:35:37+00:00"
},
{
"name": "symfony/finder",
"version": "v4.2.2",
"version": "v4.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "9094d69e8c6ee3fe186a0ec5a4f1401e506071ce"
"reference": "ef71816cbb264988bb57fe6a73f610888b9aa70c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/9094d69e8c6ee3fe186a0ec5a4f1401e506071ce",
"reference": "9094d69e8c6ee3fe186a0ec5a4f1401e506071ce",
"url": "https://api.github.com/repos/symfony/finder/zipball/ef71816cbb264988bb57fe6a73f610888b9aa70c",
"reference": "ef71816cbb264988bb57fe6a73f610888b9aa70c",
"shasum": ""
},
"require": {
@ -2640,20 +2647,20 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2019-01-03T09:07:35+00:00"
"time": "2019-01-16T20:35:37+00:00"
},
{
"name": "symfony/http-foundation",
"version": "v4.2.2",
"version": "v4.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
"reference": "a633d422a09242064ba24e44a6e1494c5126de86"
"reference": "8d2318b73e0a1bc75baa699d00ebe2ae8b595a39"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/a633d422a09242064ba24e44a6e1494c5126de86",
"reference": "a633d422a09242064ba24e44a6e1494c5126de86",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/8d2318b73e0a1bc75baa699d00ebe2ae8b595a39",
"reference": "8d2318b73e0a1bc75baa699d00ebe2ae8b595a39",
"shasum": ""
},
"require": {
@ -2694,20 +2701,20 @@
],
"description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com",
"time": "2019-01-05T16:37:49+00:00"
"time": "2019-01-29T09:49:29+00:00"
},
{
"name": "symfony/http-kernel",
"version": "v4.2.2",
"version": "v4.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-kernel.git",
"reference": "83de6543328917c18d5498eeb6bb6d36f7aab31b"
"reference": "d56b1706abaa771eb6acd894c6787cb88f1dc97d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/83de6543328917c18d5498eeb6bb6d36f7aab31b",
"reference": "83de6543328917c18d5498eeb6bb6d36f7aab31b",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/d56b1706abaa771eb6acd894c6787cb88f1dc97d",
"reference": "d56b1706abaa771eb6acd894c6787cb88f1dc97d",
"shasum": ""
},
"require": {
@ -2783,7 +2790,7 @@
],
"description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com",
"time": "2019-01-06T16:19:23+00:00"
"time": "2019-02-03T12:47:33+00:00"
},
{
"name": "symfony/polyfill-ctype",
@ -2959,16 +2966,16 @@
},
{
"name": "symfony/process",
"version": "v4.2.2",
"version": "v4.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "ea043ab5d8ed13b467a9087d81cb876aee7f689a"
"reference": "6c05edb11fbeff9e2b324b4270ecb17911a8b7ad"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/ea043ab5d8ed13b467a9087d81cb876aee7f689a",
"reference": "ea043ab5d8ed13b467a9087d81cb876aee7f689a",
"url": "https://api.github.com/repos/symfony/process/zipball/6c05edb11fbeff9e2b324b4270ecb17911a8b7ad",
"reference": "6c05edb11fbeff9e2b324b4270ecb17911a8b7ad",
"shasum": ""
},
"require": {
@ -3004,20 +3011,20 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2019-01-03T14:48:52+00:00"
"time": "2019-01-24T22:05:03+00:00"
},
{
"name": "symfony/routing",
"version": "v4.2.2",
"version": "v4.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/routing.git",
"reference": "e69b7a13a0b58af378a49b49dd7084462de16cee"
"reference": "7f8e44fc498972466f0841c3e48dc555f23bdf53"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/routing/zipball/e69b7a13a0b58af378a49b49dd7084462de16cee",
"reference": "e69b7a13a0b58af378a49b49dd7084462de16cee",
"url": "https://api.github.com/repos/symfony/routing/zipball/7f8e44fc498972466f0841c3e48dc555f23bdf53",
"reference": "7f8e44fc498972466f0841c3e48dc555f23bdf53",
"shasum": ""
},
"require": {
@ -3081,20 +3088,20 @@
"uri",
"url"
],
"time": "2019-01-03T09:07:35+00:00"
"time": "2019-01-29T09:49:29+00:00"
},
{
"name": "symfony/translation",
"version": "v4.2.2",
"version": "v4.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
"reference": "939fb792d73f2ce80e6ae9019d205fc480f1c9a0"
"reference": "23fd7aac70d99a17a8e6473a41fec8fab3331050"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/939fb792d73f2ce80e6ae9019d205fc480f1c9a0",
"reference": "939fb792d73f2ce80e6ae9019d205fc480f1c9a0",
"url": "https://api.github.com/repos/symfony/translation/zipball/23fd7aac70d99a17a8e6473a41fec8fab3331050",
"reference": "23fd7aac70d99a17a8e6473a41fec8fab3331050",
"shasum": ""
},
"require": {
@ -3154,20 +3161,20 @@
],
"description": "Symfony Translation Component",
"homepage": "https://symfony.com",
"time": "2019-01-03T09:07:35+00:00"
"time": "2019-01-27T23:11:39+00:00"
},
{
"name": "symfony/var-dumper",
"version": "v4.2.2",
"version": "v4.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
"reference": "85bde661b178173d85c6f11ea9d03b61d1212bb2"
"reference": "223bda89f9be41cf7033eeaf11bc61a280489c17"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/85bde661b178173d85c6f11ea9d03b61d1212bb2",
"reference": "85bde661b178173d85c6f11ea9d03b61d1212bb2",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/223bda89f9be41cf7033eeaf11bc61a280489c17",
"reference": "223bda89f9be41cf7033eeaf11bc61a280489c17",
"shasum": ""
},
"require": {
@ -3230,7 +3237,7 @@
"debug",
"dump"
],
"time": "2019-01-03T09:07:35+00:00"
"time": "2019-01-30T11:44:30+00:00"
},
{
"name": "tijsverkoyen/css-to-inline-styles",
@ -3281,20 +3288,21 @@
},
{
"name": "vlucas/phpdotenv",
"version": "v2.5.2",
"version": "v2.6.1",
"source": {
"type": "git",
"url": "https://github.com/vlucas/phpdotenv.git",
"reference": "cfd5dc225767ca154853752abc93aeec040fcf36"
"reference": "2a7dcf7e3e02dc5e701004e51a6f304b713107d5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/cfd5dc225767ca154853752abc93aeec040fcf36",
"reference": "cfd5dc225767ca154853752abc93aeec040fcf36",
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/2a7dcf7e3e02dc5e701004e51a6f304b713107d5",
"reference": "2a7dcf7e3e02dc5e701004e51a6f304b713107d5",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
"php": ">=5.3.9",
"symfony/polyfill-ctype": "^1.9"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.0"
@ -3302,7 +3310,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.5-dev"
"dev-master": "2.6-dev"
}
},
"autoload": {
@ -3327,7 +3335,7 @@
"env",
"environment"
],
"time": "2018-10-30T17:29:25+00:00"
"time": "2019-01-29T11:11:52+00:00"
},
{
"name": "zendframework/zend-diactoros",
@ -3397,16 +3405,16 @@
"packages-dev": [
{
"name": "barryvdh/laravel-debugbar",
"version": "v3.2.1",
"version": "v3.2.2",
"source": {
"type": "git",
"url": "https://github.com/barryvdh/laravel-debugbar.git",
"reference": "9d5caf43c5f3a3aea2178942f281054805872e7c"
"reference": "ba046deba51f3899963c7d09840bf623c4ebf5ed"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/9d5caf43c5f3a3aea2178942f281054805872e7c",
"reference": "9d5caf43c5f3a3aea2178942f281054805872e7c",
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/ba046deba51f3899963c7d09840bf623c4ebf5ed",
"reference": "ba046deba51f3899963c7d09840bf623c4ebf5ed",
"shasum": ""
},
"require": {
@ -3461,7 +3469,7 @@
"profiler",
"webprofiler"
],
"time": "2018-11-09T08:37:55+00:00"
"time": "2019-02-04T10:23:43+00:00"
},
{
"name": "doctrine/instantiator",
@ -3665,16 +3673,16 @@
},
{
"name": "laravel/browser-kit-testing",
"version": "v4.1.0",
"version": "v4.2.1",
"source": {
"type": "git",
"url": "https://github.com/laravel/browser-kit-testing.git",
"reference": "550319e457aadc11c183bd6a1c46d225cf94fbaf"
"reference": "b042ed965910a4ba69c0ebe8863d4029af3e242e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/browser-kit-testing/zipball/550319e457aadc11c183bd6a1c46d225cf94fbaf",
"reference": "550319e457aadc11c183bd6a1c46d225cf94fbaf",
"url": "https://api.github.com/repos/laravel/browser-kit-testing/zipball/b042ed965910a4ba69c0ebe8863d4029af3e242e",
"reference": "b042ed965910a4ba69c0ebe8863d4029af3e242e",
"shasum": ""
},
"require": {
@ -3706,12 +3714,12 @@
"email": "taylor@laravel.com"
}
],
"description": "Provides backwards compatibility for BrowserKit testing in Laravel 5.4.",
"description": "Provides backwards compatibility for BrowserKit testing in the latest Laravel release.",
"keywords": [
"laravel",
"testing"
],
"time": "2018-10-31T17:30:20+00:00"
"time": "2019-02-05T13:27:14+00:00"
},
{
"name": "luthfi/simple-crud-generator",
@ -3832,16 +3840,16 @@
},
{
"name": "mockery/mockery",
"version": "1.2.0",
"version": "1.2.2",
"source": {
"type": "git",
"url": "https://github.com/mockery/mockery.git",
"reference": "100633629bf76d57430b86b7098cd6beb996a35a"
"reference": "0eb0b48c3f07b3b89f5169ce005b7d05b18cf1d2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mockery/mockery/zipball/100633629bf76d57430b86b7098cd6beb996a35a",
"reference": "100633629bf76d57430b86b7098cd6beb996a35a",
"url": "https://api.github.com/repos/mockery/mockery/zipball/0eb0b48c3f07b3b89f5169ce005b7d05b18cf1d2",
"reference": "0eb0b48c3f07b3b89f5169ce005b7d05b18cf1d2",
"shasum": ""
},
"require": {
@ -3850,7 +3858,7 @@
"php": ">=5.6.0"
},
"require-dev": {
"phpunit/phpunit": "~5.7.10|~6.5|~7.0"
"phpunit/phpunit": "~5.7.10|~6.5|~7.0|~8.0"
},
"type": "library",
"extra": {
@ -3893,7 +3901,7 @@
"test double",
"testing"
],
"time": "2018-10-02T21:52:37+00:00"
"time": "2019-02-13T09:37:52+00:00"
},
{
"name": "myclabs/deep-copy",
@ -4514,16 +4522,16 @@
},
{
"name": "phpunit/phpunit",
"version": "7.5.1",
"version": "7.5.6",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "c23d78776ad415d5506e0679723cb461d71f488f"
"reference": "09c85e14994df92e5ff1f5ec0b481bdb7d3d3df9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c23d78776ad415d5506e0679723cb461d71f488f",
"reference": "c23d78776ad415d5506e0679723cb461d71f488f",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/09c85e14994df92e5ff1f5ec0b481bdb7d3d3df9",
"reference": "09c85e14994df92e5ff1f5ec0b481bdb7d3d3df9",
"shasum": ""
},
"require": {
@ -4594,7 +4602,7 @@
"testing",
"xunit"
],
"time": "2018-12-12T07:20:32+00:00"
"time": "2019-02-18T09:24:50+00:00"
},
{
"name": "sebastian/code-unit-reverse-lookup",
@ -4707,23 +4715,23 @@
},
{
"name": "sebastian/diff",
"version": "3.0.1",
"version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
"reference": "366541b989927187c4ca70490a35615d3fef2dce"
"reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/366541b989927187c4ca70490a35615d3fef2dce",
"reference": "366541b989927187c4ca70490a35615d3fef2dce",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29",
"reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29",
"shasum": ""
},
"require": {
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"phpunit/phpunit": "^7.5 || ^8.0",
"symfony/process": "^2 || ^3.3 || ^4"
},
"type": "library",
@ -4759,32 +4767,35 @@
"unidiff",
"unified diff"
],
"time": "2018-06-10T07:54:39+00:00"
"time": "2019-02-04T06:01:07+00:00"
},
{
"name": "sebastian/environment",
"version": "4.0.1",
"version": "4.1.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
"reference": "febd209a219cea7b56ad799b30ebbea34b71eb8f"
"reference": "6fda8ce1974b62b14935adc02a9ed38252eca656"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/febd209a219cea7b56ad799b30ebbea34b71eb8f",
"reference": "febd209a219cea7b56ad799b30ebbea34b71eb8f",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6fda8ce1974b62b14935adc02a9ed38252eca656",
"reference": "6fda8ce1974b62b14935adc02a9ed38252eca656",
"shasum": ""
},
"require": {
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^7.4"
"phpunit/phpunit": "^7.5"
},
"suggest": {
"ext-posix": "*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
"dev-master": "4.1-dev"
}
},
"autoload": {
@ -4809,7 +4820,7 @@
"environment",
"hhvm"
],
"time": "2018-11-25T09:31:21+00:00"
"time": "2019-02-01T05:27:49+00:00"
},
{
"name": "sebastian/exporter",
@ -5161,16 +5172,16 @@
},
{
"name": "symfony/dom-crawler",
"version": "v4.2.2",
"version": "v4.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/dom-crawler.git",
"reference": "8dc06251d5ad98d8494e1f742bec9cfdb9e42044"
"reference": "d8476760b04cdf7b499c8718aa437c20a9155103"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/8dc06251d5ad98d8494e1f742bec9cfdb9e42044",
"reference": "8dc06251d5ad98d8494e1f742bec9cfdb9e42044",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/d8476760b04cdf7b499c8718aa437c20a9155103",
"reference": "d8476760b04cdf7b499c8718aa437c20a9155103",
"shasum": ""
},
"require": {
@ -5214,7 +5225,7 @@
],
"description": "Symfony DomCrawler Component",
"homepage": "https://symfony.com",
"time": "2019-01-03T09:07:35+00:00"
"time": "2019-01-16T20:35:37+00:00"
},
{
"name": "theseer/tokenizer",

1
phpunit.xml

@ -26,6 +26,7 @@
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<env name="MAIL_DRIVER" value="log"/>
<env name="FILESYSTEM_DRIVER" value="test_storage"/>
</php>
<listeners>
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener">

20
resources/views/projects/files.blade.php

@ -42,7 +42,8 @@
{!! html_link_to_route('files.download', '', [$file->id], ['icon' => 'file', 'title' => __('file.download')]) !!}
</td>
<td class="text-center">
{!! html_link_to_route('projects.files', '', [$project->id, 'action' => 'edit', 'id' => $file->id], ['icon' => 'edit', 'title' => __('file.edit')]) !!}
{!! html_link_to_route('projects.files', '', [$project, 'action' => 'edit', 'id' => $file->id], ['icon' => 'edit', 'title' => __('file.edit')]) !!}
{!! html_link_to_route('projects.files', '', [$project, 'action' => 'delete', 'id' => $file->id], ['icon' => 'remove', 'title' => __('file.delete'), 'id' => 'delete-file-'.$file->id]) !!}
</td>
</tr>
@empty
@ -79,7 +80,22 @@
{!! Form::close() !!}
</div>
</div>
@endif
@endif
@if (Request::get('action') == 'delete' && $editableFile)
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">{{ __('file.delete') }} : {{ $editableFile->title }}</h3></div>
<div class="panel-body">{{ __('file.delete_confirm') }}</div>
<div class="panel-footer">
{!! FormField::delete(
['route' => ['files.destroy', $editableFile->id]],
__('app.delete_confirm_button'),
['class' => 'btn btn-danger'],
['file_id' => $editableFile->id, ]
) !!}
{{ link_to_route('projects.files', __('app.cancel'), $project, ['class' => 'btn btn-default']) }}
</div>
</div>
@endif
</div>
</div>

1
routes/web/projects.php

@ -61,6 +61,7 @@ Route::group(['middleware' => ['auth'], 'namespace' => 'Projects'], function ()
Route::post('files/{fileable}', ['as' => 'files.upload', 'uses' => 'FilesController@create']);
Route::get('files/{file}', ['as' => 'files.download', 'uses' => 'FilesController@show']);
Route::patch('files/{file}', ['as' => 'files.update', 'uses' => 'FilesController@update']);
Route::delete('files/{file}', ['as' => 'files.destroy', 'uses' => 'FilesController@destroy']);
});
Route::group(['middleware' => ['auth']], function () {

39
tests/Feature/Projects/UploadFilesTest.php

@ -15,7 +15,7 @@ class UploadFilesTest extends TestCase
/** @test */
public function user_can_upload_document_to_a_project()
{
Storage::fake('avatar');
Storage::fake(config('filesystem.default'));
$user = $this->adminUserSigningIn();
$project = factory(Project::class)->create();
$this->visit(route('projects.files', $project->id));
@ -38,13 +38,13 @@ class UploadFilesTest extends TestCase
]);
$file = $project->files->first();
Storage::disk('avatar')->assertExists('public/files/'.$file->filename);
Storage::assertExists('public/files/'.$file->filename);
}
/** @test */
public function user_can_edit_document_file_on_a_project()
{
Storage::fake('avatar');
Storage::fake(config('filesystem.default'));
$user = $this->adminUserSigningIn();
$project = factory(Project::class)->create();
@ -75,6 +75,37 @@ class UploadFilesTest extends TestCase
'description' => 'Edit Deskripsi file yang diuplod.',
]);
Storage::disk('avatar')->assertExists('public/files/'.$file->filename);
Storage::assertExists('public/files/'.$file->filename);
}
/** @test */
public function user_can_delete_document_file_on_a_project()
{
Storage::fake(config('filesystem.default'));
$user = $this->adminUserSigningIn();
$project = factory(Project::class)->create();
$this->visit(route('projects.files', $project));
$this->attach(UploadedFile::fake()->image('avatar.jpg'), 'file');
$this->type('Judul file', 'title');
$this->type('Deskripsi file yang diuplod.', 'description');
$this->press(__('file.upload'));
$this->assertCount(1, $project->files);
$file = $project->files->first();
Storage::assertExists('public/files/'.$file->filename);
$this->visit(route('projects.files', $project));
$this->click('delete-file-'.$file->id);
$this->seePageIs(route('projects.files', [$project, 'action' => 'delete', 'id' => $file->id]));
$this->press(__('app.delete_confirm_button'));
$this->seePageIs(route('projects.files', $project));
$this->seeText(__('file.deleted'));
$this->dontSeeInDatabase('files', ['id' => $file->id]);
Storage::assertMissing('public/files/'.$file->filename);
}
}
Loading…
Cancel
Save