×ðÁú¿­Ê±¹ÙÍøµÇ¼

laravel±íµ¥ÐÞ¸Ä

laravelÊÇÒ»ÖÖ»ùÓÚphpÓïÑÔµÄwebÓ¦ÓóÌÐò¿ò¼Ü £¬ËüΪ¿ª·¢ÕßÌṩÁËһϵÁÐÇ¿Ê¢ÇÒÒ×ÓÚʹÓõŤ¾ß £¬ÀýÈç±íµ¥´¦ÀíºÍÊý¾ÝÑéÖ¤¡£ÔÚlaravelÖÐ £¬±íµ¥Êý¾ÝµÄ´¦ÀíºÜÊǼòÆÓ £¬Ö»Ðè±àдһЩ¼òÆӵĴúÂë¼´¿ÉÍê³É¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃlaravelÀ´´¦Àí±íµ¥Ð޸IJÙ×÷¡£

½¨Éè±íµ¥

Ê×ÏÈ £¬ÐèÒª½¨ÉèÒ»¸ö±íµ¥ÒÔ±ãÓû§¿ÉÒÔÊäÈë»òÐÞ¸ÄÊý¾Ý¡£±íµ¥¿ÉÒÔÊÇÒ»¸öHTMLÎļþ £¬ÄÚÀï°üÀ¨ÁËËùÓÐµÄ±íµ¥Î»ËØ £¬ÀýÈçÊäÈë¿ò¡¢ÏÂÀ­²Ëµ¥¡¢µ¥Ñ¡¿òµÈµÈ¡£

ÔÚLaravelÖÐ £¬Í¨³£»áʹÓÃBladeÄ£°åÒýÇæÀ´äÖȾ±íµ¥¡£ÒÔÏÂÊÇÒ»¸öµä·¶µÄÁªÏµÈË±íµ¥µÄʾÀý´úÂ룺

<form method="POST" action="/contacts/update/{id}">
    @csrf
    <label for="name">Name:</label>
    <input type="text" name="name" value="{{$contact->name}}">
    <label for="phone">Phone:</label>
    <input type="text" name="phone" value="{{$contact->phone}}">
    <button type="submit">Save</button>
</form>

µÇ¼ºó¸´ÖÆ

¸Ã±íµ¥°üÀ¨ÁËÁ½¸öÊäÈë¿ò £¬ÓÃÓÚÊäÈëÁªÏµÈ˵ÄÐÕÃûºÍµç»°ºÅÂë £¬ÒÔ¼°Ò»¸öÌá½»°´Å¥¡£

´¦Àí±íµ¥Ìá½»

µ±±íµ¥±»Ìύʱ £¬ÐèÒª´¦Àí±íµ¥Êý¾Ý²¢½«ÆäÉúÑĵ½Êý¾Ý¿âÖС£ÔÚLaravelÖÐ £¬¿ÉÒÔʹÓÿØÖÆÆ÷À´´¦Àí±íµ¥Ìá½»¡£

ÒÔÏÂÊÇÒ»¸ö¼òÆӵĿØÖÆÆ÷´úÂëʾÀý£º

namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppModelsContact;

class ContactController extends Controller
{
    public function update(Request $request, $id)
    {
        $contact = Contact::find($id);
        $contact->name = $request->input('name');
        $contact->phone = $request->input('phone');
        $contact->save();

        return redirect('/contacts')->with('success', 'Contact updated!');
    }
}

µÇ¼ºó¸´ÖÆ

¸Ã¿ØÖÆÆ÷´¦ÀíÁË±íµ¥µÄÌá½» £¬´ÓÊý¾Ý¿âÖвéÕÒ³öÁªÏµÈËÐÅÏ¢ £¬½«Ð޸ĺóµÄÐÅÏ¢ÉúÑĵ½Êý¾Ý¿âÖÐ £¬×îºóÖض¨Ïòµ½ÁªÏµÈËÁбíÒ³Ãæ¡£

·ÓÉÉèÖÃ

½ÓÏÂÀ´ £¬ÐèҪΪ±íµ¥Ìá½»ÉèÖÃÒ»¸ö·ÓɹæÔò¡£ÔÚLaravelÖÐ £¬¿ÉÒÔʹÓ÷ÓÉÀ´½«HTTPÇëÇóÓ³Éäµ½ÏìÓ¦µÄ¿ØÖÆÆ÷º¯Êý¡£ÒÔÏÂÊÇÒ»¸öµä·¶µÄ·ÓÉʾÀý£º

Route::post('/contacts/update/{id}', [ContactController::class, 'update'])->name('contacts.update');

µÇ¼ºó¸´ÖÆ

ÔÚÒÔÉÏ·ÓɹæÔòÖÐ £¬ÎÒÃÇʹÓÃÁËPOSTÇëÇóµÄ·½·¨Ìá½»±íµ¥ £¬²¢½«ÇëÇóÓ³Éäµ½ContactController¿ØÖÆÆ÷µÄupdateº¯Êý¡£Í¬Ê± £¬Â·ÓɹæÔòÒ²½ç˵ÁËÒ»¸öÃûΪ¡°contacts.update¡±µÄ·ÓÉÓÖÃû £¬ÒÔºóÔÚÌìÉúURLÖпÉÒÔʹÓøÃÓÖÃû¡£

Íê³É±íµ¥Ð޸IJÙ×÷

ÏÖÔÚ £¬µ±Óû§Ìá½»±íµ¥Ê± £¬±íµ¥Êý¾Ý½«»á±»Ìá½»µ½LaravelµÄ·ÓÉÖÐ £¬²¢½»ÓÉContactController¿ØÖÆÆ÷µÄupdateº¯Êý¾ÙÐд¦Àí¡£¸Ãº¯Êý»á»ñÈ¡±íµ¥Êý¾Ý²¢¸üÐÂÏìÓ¦µÄÁªÏµÈËÐÅÏ¢ £¬×îºóÖض¨Ïòµ½ÁªÏµÈËÁбíÒ³Ãæ £¬²¢ÏÔʾһ¸öÀÖ³ÉÌáÐÑÐÅÏ¢¡£

×ÛÉÏ £¬±¾ÎÄÏÈÈÝÁËLaravel¿ò¼ÜÏÂ±íµ¥Ìá½»ºÍÊý¾Ý¸üеĴ¦Àí·½·¨¡£LaravelÌṩÁ˱ã½ÝÇÒÒ×ÓÚʹÓÃµÄ±íµ¥´¦Àí¹¤¾ß £¬¿ÉÒÔʹ¿ª·¢ÕßÔ½·¢×¨×¢ÓÚÓªÒµÂß¼­¿ª·¢¡£ÓÐÁËÕâЩ¹¤¾ßµÄ×ÊÖú £¬¿ª·¢Õß¿ÉÒÔÔ½·¢¸ßЧµØÍê³É±íµ¥Ïà¹ØÊÂÇé¡£

ÒÔÉϾÍÊÇlaravel±íµ¥Ð޸ĵÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

13452372176

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

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

QR code
ÍøÕ¾µØͼ