Squashed commit of the following: commit 5b958d42bcfdce94e742d9602217818c398fb993 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Mon Nov 20 15:56:54 2017 +0000 pyrus has been dropped by travis, even thouhgt its still in the docs commit 33cb7ac72ad16af3df2c7a10daeb99fbe3b0a08c Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Mon Nov 20 15:45:14 2017 +0000 Use pyrus/pear2 to install phpcs, and configure with phpcs.xml commit 9781b036681e28ab9bb85f7a060e26d061118685 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Mon Nov 20 14:51:44 2017 +0000 Fix phpcs issues commit b165cd2a133113138a24c72a5df320a6ad397dac Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Mon Nov 20 13:48:18 2017 +0000 Let’s read the whole travis help doc commit e0f84ed388a83350fd76ac8586291a57c65df6c7 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Mon Nov 20 13:44:55 2017 +0000 Try adding phpcs to travis
36 lines
838 B
PHP
36 lines
838 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Like;
|
|
use App\Jobs\ProcessLike;
|
|
use Illuminate\Http\Request;
|
|
|
|
class LikeService
|
|
{
|
|
/**
|
|
* Create a new Like.
|
|
*
|
|
* @param Request $request
|
|
*/
|
|
public function createLike(Request $request): Like
|
|
{
|
|
if ($request->header('Content-Type') == 'application/json') {
|
|
//micropub request
|
|
$url = normalize_url($request->input('properties.like-of.0'));
|
|
}
|
|
if (($request->header('Content-Type') == 'x-www-url-formencoded')
|
|
||
|
|
($request->header('Content-Type') == 'multipart/form-data')
|
|
) {
|
|
$url = normalize_url($request->input('like-of'));
|
|
}
|
|
|
|
$like = Like::create(['url' => $url]);
|
|
ProcessLike::dispatch($like);
|
|
|
|
return $like;
|
|
}
|
|
}
|