You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

52 lines
1.5 KiB

<?php
namespace Tests\Feature\Traits;
use App\Models\Collection;
use App\Models\File;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
trait FileShowTrait
{
use FileImageTrait;
public function dimensions(\Illuminate\Http\File $image, $minWidth, $minHeight, $maxWidth, $maxHeight, $maxSize, $minSize) : bool
{
$data = [
'image' => $image
];
$validator = Validator::make($data, [
'avatar' => [
Rule::dimensions()->minWidth($minWidth)->minHeight($minHeight)->maxWidth($maxWidth)->maxHeight($maxHeight),
'max:' . $maxSize,
'min:' . $minSize
],
]);
return !$validator->fails();
}
public function createCollectionAndFileModelWithImage()
{
$collection = Collection::factory()->createQuietly([
'alt_required' => false,
'description_required' => false,
'tmp_support' => true,
'max_width' => 2000,
'max_height' => 2000,
'min_width' => 1,
'min_height' => 1,
'min_file_size' => 0
]);
$uuid = app()->uuid;
$file = File::factory()->createQuietly([
'uuid' => $uuid,
'server_path' => '/' . date('y') . '/' . date('m') . '/',
'user_id' => auth()->id(),
'collection_id' => $collection->id
]);
$this->createImageForModel($collection,$file);
return ['file' => $file ,'collection' => $collection];
}
}