38 lines
862 B
PHP
38 lines
862 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Web;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\LinkConverterService;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ConvertController extends Controller
|
|
{
|
|
protected LinkConverterService $linkConverterService;
|
|
|
|
public function __construct(LinkConverterService $linkConverterService)
|
|
{
|
|
$this->linkConverterService = $linkConverterService;
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
return view('convert.index');
|
|
}
|
|
|
|
public function process(Request $request)
|
|
{
|
|
$request->validate([
|
|
'url' => 'required|url',
|
|
]);
|
|
|
|
$result = $this->linkConverterService->process($request->input('url'));
|
|
|
|
if ($result->isSuccess) {
|
|
return back()->with('success_result', $result);
|
|
}
|
|
|
|
return back()->with('error_result', $result);
|
|
}
|
|
}
|