<?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')) {
            if ($request->has('url')) {
                $url = new Url();
                $url->original_url = $request->input('url');
                $url->shortened_url = Shortener::shorten($request->input('url'));
                $url->save();
                \Session::flash('message', 'Record saved');
            }

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

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

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

        return view('url.view', [
            'urls' => $urls,
            'message' => \Session::get('message')
        ]);
    }
}

<?php

namespace App\Http\Controllers;

use App\Url;
use Illuminate\Http\Request;
use Illuminate\Session\Store;
use Illuminate\Validation\Factory as Validator;
use Zenapply\Shortener\Facades\Shortener;

class UrlController extends Controller
{
    public function manageUrl(Request $request, Store $session, Validator $validator)
    {
        if ($request->isMethod('post')) {
            if ($request->has('url')) {
                $url = new Url();
                $url->original_url = $request->input('url');
                $url->shortened_url = Shortener::shorten($request->input('url'));
                $url->save();
                \Session::flash('message', 'Record saved');
            }

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

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

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

        return view('url.view', [
            'urls' => $urls,
            'message' => \Session::get('message')
        ]);
    }
}

Replace use of Laravel Facades with dependency injection
Replace use of Laravel Facades with dependency injection

I'm not a huge fan of the Laravel Facades concept. But I get why it's
there. So this moves me away from that, making the code both clearer, as
well as easier for the IDE (PhpStorm of course) to figure out what's going on.
