oxbir
1 month ago
205
3
Laravel

How to change the best code?

Posted 1 month ago by oxbir

I downloaded a package my friend. The coding of this package is not suitable in my opinion. I want to rename to rand(11111111,99999999).

default package

public function dropzone(Request $request)
{
    if($request->hasFile('file') && $slider = $request->file('file')) {
        return response([
            'slider'=> \Storage::disk('custom')
                ->put('images/design-studios', $slider, 'public'),
        ]);
    }
}

rename

public function dropzone(Request $request)
{
    $randomize = rand(1111111, 9999999);
    if($request->hasFile('file') && $slider = $request->file('file')) {
        return response([
            'slider'=> move_uploaded_file($randomize, public_path('images/design-studios')),
        ]);
    }
}

Please sign in or create an account to participate in this conversation.