All cruds work well both on shared hosting and localhost except create (store).
here is my addtoqueue controller:
public function store(Request $request)
{
$last = antri::whereDate('created_at', Carbon::today())->latest()->first();
if ( $last ) {
$tambah = $last->number + 1;
}
else {
$tambah = 1;
}
$newantri = new antri;
$newantri->user_id = $request->user_id;
$newantri->number = $tambah;
$newantri->called = 0;
$newantri->save();
return $newantri;
}
model:
class antri extends Model
{
use HasFactory;
}
api route :
Route::post('queue', [addtoqueue::class, 'store']);
the trigger:
<v-btn elevation="2" v-on:click="increase" >Ambil Nomor Antrian</v-btn>
the script:
methods: {
increase: function() {
axios.post('/api/queue/', {
user_id: this.user.id
})
. then( response=> {
if( response.status == 200 ) {
this.$emit('itemchanged');
}
})
. catch( error => {
console.log(error);
})
window.location.reload();
}
tested using postman worked well too on both local and share hosting database.
can anyone figure out what seems to be the problem?