尊龙凯时人生就是搏

ThinkPHP6ÖÐÔõÑù¾ÙÐÐÅúÁ¿²Ù×÷£¿

Ëæ×ÅwebÓ¦ÓóÌÐòµÄÒ»Ö±Éú³¤£¬ÅúÁ¿²Ù×÷ÒѳÉΪwebÓ¦ÓóÌÐòÖбز»¿ÉÉٵĹ¦Ð§Ö®Ò»¡£¶øÔÚʹÓÃthinkphp6¾ÙÐпª·¢Ê±£¬´¦ÀíÅúÁ¿²Ù×÷Ò²±äµÃÒ×ÓÚʵÏÖ¡£

ÔÚThinkPHP6ÖУ¬¿ØÖÆÆ÷ͨ³£ÓÃÓÚ´¦ÀíÇëÇóºÍÏìÓ¦ÇëÇó¡£ÈôÊÇҪʵÏÖÅúÁ¿²Ù×÷£¬ÎÒÃÇÐèҪʹÓÿØÖÆÆ÷´¦Àí´«ÈëµÄÇëÇó£¬È»ºó½«ÇëÇó·Ö·¢µ½ÏìÓ¦µÄ²Ù×÷ÒªÁìÖоÙÐд¦Àí¡£Õâ¿ÉÒÔͨ¹ýʹÓÿØÖÆÆ÷ÖеÄforeachÑ­»·À´ÊµÏÖ¡£

ÏÂÃæÎÒÃǽ«Ïêϸ̽ÌÖÔõÑùʹÓÃThinkPHP6¾ÙÐÐÅúÁ¿²Ù×÷¡£

µÚÒ»²½£º½ç˵·ÓÉ

Ê×ÏÈ£¬ÎÒÃÇÒª½ç˵һ¸ö·ÓÉÀ´Æ¥ÅäÅúÁ¿²Ù×÷µÄÇëÇó¡£ÎÒÃÇ¿ÉÒÔÔÚ·ÓÉÎļþÖÐʹÓÃÈçÏ´úÂ룺

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡± £»

Route::post('user/:id/batch', 'user/batch');

µÇ¼ºó¸´ÖÆ

Õ⽫ƥÅäÒ»¸öHTTP POSTÇëÇó£¬ÆäURLģʽΪ/user/:id/batch£¬ÆäÖÐ:idÊÇÓû§µÄID¡£

µÚ¶þ²½£º½ç˵¿ØÖÆÆ÷

½Ó×Å£¬ÎÒÃÇÐèÒª½ç˵һ¸ö¿ØÖÆÆ÷À´´¦ÀíÅúÁ¿²Ù×÷µÄÇëÇó¡£ÎÒÃÇ¿ÉÒÔÔÚ¿ØÖÆÆ÷Öнç˵һ¸öbatchÒªÁ죬ÓÃÓÚÎüÊպʹ¦ÀíÇëÇó¡£ÎÒÃÇ¿ÉÒÔʹÓÃÈçÏ´úÂ룺

public function batch($id)
{
    // »ñÈ¡Òª¾ÙÐÐÅúÁ¿²Ù×÷µÄÓû§IDÊý×é
    $userIds = Request::post('user_ids/a');

    // ¼ì²éÓû§IDÊý×éÊÇ·ñΪ¿Õ
    if (empty($userIds)) {
        return $this->error('ÇëÑ¡ÕªÒª²Ù×÷µÄÓû§!', 'index');
    }

    // ¶ÔÓû§¾ÙÐÐÅúÁ¿²Ù×÷
    foreach ($userIds as $userId) {
        // TODO: ÔÚÕâÀïÌí¼ÓÏêϸµÄ²Ù×÷´úÂë
    }

    return $this->success('ÅúÁ¿²Ù×÷ÀÖ³É!', 'index');
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÊö´úÂëÖУ¬ÎÒÃÇʹÓÃÁËRequestÀàÀ´»ñÈ¡POSTÇëÇóÖеÄuser_ids²ÎÊý£¬¸Ã²ÎÊýÊÇÒ»¸ö°üÀ¨Òª²Ù×÷µÄÓû§IDµÄÊý×顣Ȼºó£¬ÎÒÃǼì²é¸ÃÊý×éÊÇ·ñΪ¿Õ£¬ÈôÊÇΪ¿Õ£¬Ôò·µ»ØÒ»¸ö¹ýʧ¡£²»È»£¬ÎÒÃÇʹÓÃforeachÑ­»·À´±éÀú¸ÃÊý×飬²¢¶Ôÿ¸öÓû§Ö´ÐÐÏêϸµÄ²Ù×÷¡£

µÚÈý²½£ºÌí¼ÓHTML´úÂë

×îºó£¬ÎÒÃÇÒªÌí¼ÓÒ»¸öHTML±íµ¥À´Ìá½»ÅúÁ¿²Ù×÷µÄÇëÇó¡£ÎÒÃÇ¿ÉÒÔÔÚHTML±íµ¥ÖÐʹÓÃÈçÏ´úÂ룺

<form method="post" action="/user/{$id}/batch">
    <button type="submit" name="action" value="delete">ɾ³ý</button>
    <button type="submit" name="action" value="enable">ÆôÓÃ</button>
    <button type="submit" name="action" value="disable">½ûÓÃ</button>

    <input type="hidden" name="user_ids[]" value="1">
    <input type="hidden" name="user_ids[]" value="2">
    <input type="hidden" name="user_ids[]" value="3">
    <!-- ÆäËûÓû§ID -->
</form>

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÊö´úÂëÖУ¬ÎÒÃÇʹÓÃÁËPOSTÇëÇóÌáÊǵÄÈý¸ö°´Å¥£¬»®·Ö´ú±íɾ³ý¡¢ÆôÓúͽûÓòÙ×÷¡£ÎÒÃÇ»¹Í¨¹ýinput±êÇ©ÖеÄuser_idsÊý×é²ÎÊýÀ´Ö¸¶¨Òª²Ù×÷µÄÓû§ID£¬¿ÉÒÔƾ֤ÏÖʵÐèÇóÀ´Ìí¼ÓÐ޸ġ£

×¢ÖØ£ºÕâÖ»ÊÇÒ»ÖÖʵÏÖÅúÁ¿²Ù×÷µÄʾÀý¡£ÔÚÏÖʵÏîÄ¿ÖУ¬ÄúÐèҪƾ֤×Ô¼ºµÄÐèÇóÀ´±àд×Ô¼ºµÄ´úÂë¡£

×ܽ᣺

±¾ÎÄÏÈÈÝÁËÔõÑùÔÚThinkPHP6ÖÐʵÏÖÅúÁ¿²Ù×÷¡£ÎÒÃÇÏȽç˵ÁËÒ»¸ö·ÓÉ£¬È»ºóÔÚ¿ØÖÆÆ÷Öнç˵ÁËÒ»¸öÓÃÓÚ´¦ÀíÅúÁ¿²Ù×÷µÄÒªÁì¡£×îºó£¬ÎÒÃÇÌí¼ÓÁËÒ»¸öHTML±íµ¥À´Ìá½»ÅúÁ¿²Ù×÷ÇëÇó¡£Í¨¹ýÕâЩ°ì·¨£¬ÎÒÃǾͿÉÒÔÔÚÎÒÃǵÄWebÓ¦ÓóÌÐòÖÐʵÏÖÅúÁ¿²Ù×÷ÁË¡£

ÒÔÉϾÍÊÇThinkPHP6ÖÐÔõÑù¾ÙÐÐÅúÁ¿²Ù×÷£¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ