Button onclick Number in DB +1 Laravel

I wanna know if its possible.

If I have a database with a table and there is an entry with an int parameter who is 0.

In my view i can see the number is : 0

and then i wanna have a button and onclick it should be + 1 in my database and it should show me this number per ajax.

Is this possible so can Laravel work with ajax and js?

I wanna do it like this:

Controller:

function ($count) {

$number= DB::(‘number’)->first;
if (isset($count)) {
$count = $number + 1;
} else {
$count = $number;
}

and view:

a form with a button with the function count?

i am new so it is only me thinking about something

but it is possible and am i on the right way?

#ajax #database #laravel

5 Likes21.85 GEEK