app/Http/Controllers/UrlController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \App\Http\Requests\StoreUrlRequest  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(StoreUrlRequest $request)
    {
        $newUrl = $request->validated();
        if (!$request->filled('custom_key')) {
            $newUrl["custom_key"] = $this->generateRandomString();
        }
        Url::create($newUrl);
        return redirect()->route('url.index')
            ->with('success', 'Url created successfully.')
            ->with('short_link', env('APP_SHORT_URL') . $newUrl["custom_key"]);
    }
public function store ( StoreUrlRequest $ request ) { $ newUrl = $ request -> validated ( ) ; if ( ! $ request -> filled ( 'custom_key' ) ) { $ newUrl [ " custom_key " ] = $ this -> generateRandomString ( ) ; } Url :: create ( $ newUrl ) ; return redirect ( ) -> route ( 'url.index' ) -> with ( 'success' , 'Url created successfully.' ) -> with ( 'short_link' , env ( 'APP_SHORT_URL' ) . $ newUrl [ " custom_key " ] ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .