app/Http/Controllers/LinkController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(CreateLink $request)
    {
        $input = $request->all();
        $input['input_url'] =  $request->input_url . '_'. Str::random(5);
        if (Auth::check()) {
            $input['user_id'] = Auth::user()->email;
        } else {
            $input['user_id'] = 'guest';
        }
        if(Link::create($input)) {
            $input['input_url'] = "wann.fun/" . $input['input_url'];
            return redirect()->action([LinkController::class, 'index'])->with([
                'url' => $input["input_url"],
                'linkCreated' => 'true'
            ]);
        }
        return back()->with('error', 'Link creation error');
    }
public function store ( CreateLink $ request ) { $ input = $ request -> all ( ) ; $ input [ 'input_url' ] = $ request -> input_url . '_' . Str :: random ( 5 ) ; if ( Auth :: check ( ) ) { $ input [ 'user_id' ] = Auth :: user ( ) -> email ; } else { $ input [ 'user_id' ] = 'guest' ; } if ( Link :: create ( $ input ) ) { $ input [ 'input_url' ] = " wann.fun/ " . $ input [ 'input_url' ] ; return redirect ( ) -> action ( [ LinkController :: class , 'index' ] ) -> with ( [ 'url' => $ input [ " input_url " ] , 'linkCreated' => 'true' ] ) ; } return back ( ) -> with ( 'error' , 'Link creation error' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .