dimanche 13 mars 2016

How to limit user requests per hour in laravel

I have a site that has few request options (for example add friend). I want to limit of requests made by use per certain time, for example so he can't send more than 5 friend requests within hour.

QUESTION How Can I achieve this?

I have written following query

$result = DB::table('bubble_users')
                     ->select(DB::raw('count(*) as user_count, status'))
                     ->where('status', '=', "pending")
                     ->where('user_id','=', $user_id)
                     ->where(DB::raw('DATE_ADD(created_at, INTERVAL 1 HOUR) > NOW()'))
                     ->groupBy('status')
                     ->get();

But I'm not getting wrong response

Anybody help me!!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire