Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
21d8e7695b
3 changed files with 40 additions and 4 deletions
|
@ -26,17 +26,16 @@ class LocationsFilesController extends Controller
|
|||
*/
|
||||
public function store(UploadFileRequest $request, Location $location) : RedirectResponse
|
||||
{
|
||||
|
||||
$this->authorize('update', $location);
|
||||
|
||||
if ($request->hasFile('file')) {
|
||||
|
||||
if (! Storage::exists('private_uploads/locations')) {
|
||||
Storage::makeDirectory('private_uploads/locations', 775);
|
||||
}
|
||||
|
||||
foreach ($request->file('file') as $file) {
|
||||
|
||||
$file_name = $request->handleFile('private_uploads/locations/','model-'.$location->id,$file);
|
||||
$file_name = $request->handleFile('private_uploads/locations/','location-'.$location->id, $file);
|
||||
$location->logUpload($file_name, $request->get('notes'));
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
<label for="min_amt" class="col-md-3 control-label">{{ trans('general.min_amt') }}</label>
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-2" style="padding-left:0px">
|
||||
<input class="form-control col-md-3" maxlength="5" type="text" name="min_amt" id="min_amt" aria-label="min_amt" value="{{ old('min_amt', ($item->min_amt ?? '')) }}"{{ (isset($item) ?? (Helper::checkIfRequired($item, 'min_amt')) ? ' required' : '') }}/>
|
||||
<input class="form-control col-md-3" maxlength="5" type="text" name="min_amt" id="min_amt"
|
||||
aria-label="min_amt"
|
||||
value="{{ old('min_amt', ($item->min_amt ?? '')) }}"
|
||||
{{ (isset($item) && (Helper::checkIfRequired($item, 'min_amt')) ? ' required' : '') }}/>
|
||||
</div>
|
||||
<div class="col-md-7" style="margin-left: -15px;">
|
||||
|
||||
|
|
|
@ -4,7 +4,10 @@ namespace Tests\Feature\Locations\Ui;
|
|||
|
||||
use App\Models\Location;
|
||||
use App\Models\User;
|
||||
use App\Models\Actionlog;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class UpdateLocationsTest extends TestCase
|
||||
{
|
||||
|
@ -75,5 +78,36 @@ class UpdateLocationsTest extends TestCase
|
|||
}
|
||||
|
||||
|
||||
public function testFileIsUploadedAndLogged()
|
||||
{
|
||||
$location = Location::factory()->create();
|
||||
Storage::fake('local');
|
||||
$file = UploadedFile::fake()->image('file.jpg', 100, 100)->size(100);
|
||||
|
||||
$this->actingAs(User::factory()->superuser()->create())
|
||||
->post(route('upload/locations', $location), [
|
||||
'file' => [$file],
|
||||
'notes' => 'Test Upload',
|
||||
])
|
||||
->assertStatus(302)
|
||||
->assertSessionHasNoErrors();
|
||||
|
||||
|
||||
$location->refresh();
|
||||
|
||||
$logentry = Actionlog::where('item_type', Location::class)
|
||||
->where('item_id', $location->id)
|
||||
->where('action_type', 'uploaded')
|
||||
->first();
|
||||
|
||||
$this->assertTrue(Actionlog::where('item_type', Location:: class)->where('item_id', $location->id)->where('filename', $logentry->filename)->exists());
|
||||
|
||||
|
||||
// Assert the file was stored...
|
||||
// This doesn't work with the way we handle files :( Should try to fix this.
|
||||
// Storage::disk('local')->assertExists($logentry->filename);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue