demo/app/Modules/Torrent/Tasks/StoreTask.php
2023-03-23 18:50:47 +01:00

39 lines
781 B
PHP

<?php
namespace LaraBB\Torrent\Tasks;
use LaraBB\Torrent\Models\Torrent;
/**
*
*/
class StoreTask
{
/**
* @param Torrent $torrent
*/
public function __construct(
private readonly Torrent $torrent
) {
}
/**
* @param array $data
* @return Torrent
*/
public function run(array $data): Torrent
{
$this->torrent->created_uuid = $data['created_uuid'];
$this->torrent->updated_uuid = $data['updated_uuid'];
$this->torrent->infohash = $data['infohash'];
$this->torrent->filename = $data['filename'];
$this->torrent->name = $data['name'];
$this->torrent->size = $data['size'];
$this->torrent->save();
return $this->torrent;
}
}