Repo for the search and displace core module including the interface to select files and search and displace operations to run on them. https://searchanddisplace.com
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.
 
 
 
 
 
 

37 lines
927 B

<?php
namespace App\SearchDisplace\Ingest;
use Illuminate\Support\Facades\Storage;
class HandleReceivedDocument
{
protected $id;
protected $content;
protected $status;
public function __construct($payload)
{
$this->id = $payload['data']['id'];
$this->content = $payload['data']['content'];
$this->status = $payload['data']['status'];
}
public function handle()
{
$storage = Storage::disk('local');
$fileName = $this->id;
// The .md extension signals the success status, the lack of signals the fail status.
if ($this->status === 'success') {
$fileName = $fileName . '.md';
}
try {
$storage->put("contracts/${fileName}", $this->content);
} catch (\Exception $exception) {
\Illuminate\Support\Facades\Log::info('exception. :' . $exception->getMessage());
}
}
}