Take a screenshot of the bookmark
This commit is contained in:
parent
a5d3ba7829
commit
33cf91f6d5
10 changed files with 1854 additions and 1456 deletions
45
app/Jobs/ProcessBookmark.php
Normal file
45
app/Jobs/ProcessBookmark.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Bookmark;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Spatie\Image\Manipulations;
|
||||
use Spatie\Browsershot\Browsershot;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
|
||||
class ProcessBookmark implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
protected $bookmark;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Bookmark $bookmark)
|
||||
{
|
||||
$this->bookmark = $bookmark;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Browsershot $browsershot)
|
||||
{
|
||||
$uuid = Uuid::uuid4();
|
||||
$browsershot->url($this->bookmark->url)
|
||||
->windowSize(960, 640)
|
||||
->save(public_path() . '/assets/img/bookmarks/' . $uuid . '.png');
|
||||
$this->bookmark->screenshot = $uuid;
|
||||
$this->bookmark->save();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue