Add 'plugi-core/' from commit '6c478c54d048ab2fd5af4e8e79074153fb594c16'

git-subtree-dir: plugi-core
git-subtree-mainline: d4c734cdbd
git-subtree-split: 6c478c54d0
This commit is contained in:
Paul Spenke
2023-06-13 07:27:11 +08:00
151 changed files with 46689 additions and 0 deletions
@@ -0,0 +1,45 @@
<?php
namespace Plugi\Repositories;
use Plugi\UploadedFile;
class UploadRepository extends BaseRepository
{
/**
* The uploads database table.
*
* @var string
*/
protected $table = 'uploads';
/**
* The class that represents each uploaded file.
*
* @var string
*/
protected $class = UploadedFile::class;
/**
* Create a new uploaded file.
*
* @param array $data
* @return bool|object
*/
public function create(array $data)
{
$fields = ['public_id', 'original_file', 'mime_type', 'server_file'];
foreach ($fields as $field) {
if (! isset($data[$field]) || ! is_string($data[$field])) {
return false;
}
}
return parent::create([
'public_id' => $data['public_id'],
'original_file' => $data['original_file'],
'mime_type' => $data['mime_type'],
'server_file' => $data['server_file'],
]);
}
}