<?php

namespace App\Http\Controllers;

use App\Url;
use Illuminate\Http\Request;

class UrlController extends Controller
{
    public function manageUrl(Request $request)
    {
        return view('url.manage', []);
    }

    public function viewUrls()
    {
        $urls = Url::all();

        return view('url.view', ['urls' => $urls]);
    }
}

<?php

namespace App\Http\Controllers;

use App\Url;
use Illuminate\Http\Request;
use Zenapply\Shortener\Facades\Shortener;

class UrlController extends Controller
{
    public function manageUrl(Request $request)
    {
        if ($request->isMethod('post')) {
            $url = new Url();
            $url->original_url = $request->input('url');
            $url->shortened_url = Shortener::shorten($request->input('url'));
            $url->save();

            return redirect('/view-urls');
        }

        return view('url.manage', []);
    }

    public function viewUrls()
    {
        $urls = Url::all();

        return view('url.view', ['urls' => $urls]);
    }
}

Add basic support for creating urls
Add basic support for creating urls

Here I'm implementing a VERY rudimentary controller action for creating
URLs. No, it doesn't do any kind of validation or any other form of
sanitisation or defensive coding. I'm well aware of that. But that will
change over coming commits.
