濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > laravel ajax curd 搜索登錄判斷功能的實(shí)現(xiàn)

laravel ajax curd 搜索登錄判斷功能的實(shí)現(xiàn)

熱門(mén)標(biāo)簽:廣西智能外呼系統(tǒng)多少錢(qián) 大學(xué)校門(mén)地圖標(biāo)注 平?jīng)龈叩碌貓D標(biāo)注商戶(hù)要收費(fèi)嗎 銷(xiāo)售電銷(xiāo)機(jī)器人詐騙 荊州智能電銷(xiāo)機(jī)器人 地圖標(biāo)注與公司業(yè)務(wù)關(guān)系 福建微碼電話(huà)機(jī)器人 提高電話(huà)機(jī)器人接通率 外呼系統(tǒng)api對(duì)接

今天來(lái)說(shuō)說(shuō)關(guān)于laravel的各種操作 混雜了一點(diǎn)ajax先來(lái)個(gè)添加表單
有些英文的$沒(méi)法打出來(lái)用中文代替
登錄數(shù)據(jù)我和列表展示混在一起了,千萬(wàn)不要和我犯一樣的錯(cuò)誤。

form action="insert" method="post" enctype="multipart/form-data">
    @csrf
    div style="width: 600px;height: auto;margin: 20px auto 0;">
        table>
            tr>
                td>
                    用戶(hù)名:
                /td>
                td>
                    input type="text" class="form-control" name="user">
                /td>
            /tr>
            tr>
                td>
                    昵稱(chēng):
                /td>
                td>
                    input type="text" class="form-control" name="name">
                /td>
            /tr>
            tr>
                td>
                    密碼:
                /td>
                td>
                    input type="password" class="form-control" name="password">
                /td>
            /tr>
            tr>
                td>
                    確認(rèn)密碼
                /td>
                td>
                    input type="password" class="form-control" name="password2">
                /td>
            /tr>
            tr>
                td>
                    身份指定
                /td>
                td>
                    select name="i_id" class="form-control">
                        @foreach($arr as $v)
                            option value="{{$v->id}}">{{$v->identity}}/option>
                        @endforeach
                    /select>
                /td>
            /tr>
            tr>
                td>
                    狀態(tài)
                /td>
                td>
                    select name="status" class="form-control">
                        option value="0">啟用/option>
                        option value="1">未啟用/option>
                    /select>
                /td>
            /tr>
            tr>
                td>
                    手機(jī)號(hào)
                /td>
                td>
                    input type="text" class="form-control" name="tel">
                /td>

            /tr>
            tr>
                td>
                    IP白名單1
                /td>
                td>
                    input type="text" class="form-control" name="ip1">
                /td>
            /tr>
            tr>
                td>
                    IP白名單2
                /td>
                td>
                    input type="text" class="form-control" name="ip2">
                /td>
            /tr>
            tr>
                td>
                    頭像上傳
                /td>
                td>
                    input type="file" name="img">
                /td>
            /tr>
            tr>
                td>/td>
                td>
                    button type="submit" class="btn btn-primary">增加/button>
                    button class="btn btn-primary">
                        a href="show" rel="external nofollow"  rel="external nofollow"  style="color: white;text-decoration: none">展示/a>
                    /button>
                /td>
            /tr>
        /table>
    /div>
/form>

然后是添加的控制器

public function insert(Request $request){
$validatedData = $request->validate([
‘user' => ‘required',
‘name' => ‘required',
‘password' => ‘required',
‘i_id' => ‘required',
‘status' => ‘required',
‘tel' => ‘required',
‘ip1' => ‘required',
‘img' => ‘required',
]);
$data[‘user'] = $request[‘user'];
$data[‘name'] = $request[‘name'];
$data[‘password'] = $request[‘password'];
$data[‘i_id'] = $request[‘i_id'];
$data[‘status'] = $request[‘status'];
$data[‘tel'] = $request[‘tel'];
$data[‘ip1'] = $request[‘ip1'];
$data[‘ip2'] = $request[‘ip2'];
u r l = ′ h t t p : / / w w w . d 19. c o m / ′ ; ¥ p a t h = url = 'http://www.d19.com/'; ¥path =url= 
′
 http://www.d19.com/ 
′
 ;¥path=url.$request->file(‘img')->store(‘img');
$data[‘img'] = p a t h ; ¥ s s = L i s t m o d e l : : u − i n s e r t ( path; ¥ss = Listmodel::u-insert(path;¥ss=Listmodel::u−insert(data);
if ($ss){
echo "script>alert('添加成功');window.location.href='show'/script> ";
}else{
echo "script>alert('添加失敗,請(qǐng)重新輸入');window.location.href='create'/script> ";
}
}

下面是展示頁(yè)面,展示頁(yè)面包括了ajax無(wú)刷新刪除 添加跳轉(zhuǎn)、修改跳轉(zhuǎn)、批量刪除、搜索頁(yè)面、因?yàn)槲覀冃枰涗浀卿洜顟B(tài),還要一個(gè)退出登錄按鈕、當(dāng)然還有分頁(yè)、我們直接放body的

 form action="">
        input type="text" name="user">
        button class="btn btn-primary">搜索/button>
        button class="btn btn-primary">a href="clearn" rel="external nofollow"  style="color: #ffffff;text-decoration: none">退出登錄/a>/button>
    /form>
    button id="batch" class="btn btn-primary">
        批量刪除
    /button>
    button class="btn btn-primary">
        a href="create" rel="external nofollow"  style="text-decoration: none;color: white">添加信息/a>
    /button>
    table class="table">
        thead class="thead-dark">
        tr>
            th scope="col">
                span id="getall" style="cursor: pointer">全選/span>/
                span id="noall" style="cursor: pointer">全不選/span>/
                span id="no" style="cursor: pointer">反選/span>
            /th>
            th scope="col">
                編號(hào)
            /th>
            th scope="col">
                賬號(hào)
            /th>
            th scope="col">
                昵稱(chēng)
            /th>
            th scope="col">
                身份
            /th>
            th scope="col">
                狀態(tài)
            /th>
            th scope="col">
                電話(huà)
            /th>
            th scope="col">
                ip地址1
            /th>
            th scope="col">
                ip地址2
            /th>
            th scope="col">
                圖片
            /th>
            th scope="col">
                操作
            /th>
        /tr>
        /thead>
        @foreach( $arr as $v)
            tr>
                td>
                    input type="checkbox" name="check" class="zi" checkid="{{$v->id}}">
                /td>
                td>
                    {{$v->id}}
                /td>
                td>
                    {{$v->user}}
                /td>
                td>
                    {{$v->name}}
                /td>
                td>
                    {{$v->i_id}}
                /td>
                td>
                    @if($v->status == 0)
                        啟用
                    @elseif($v->status == 1)
                        未啟用
                    @endif
                /td>
                td>
                    {{$v->tel}}
                /td>
                td>
                    {{$v->ip1}}
                /td>
                td>
                    {{$v->ip2}}
                /td>
                td>
                    img src="{{$v->img}}" style="width: 30px;height: 30px;">

                /td>
                td>
                    button class="btn btn-danger dele2" d_id="{{$v->id}}"> 刪除/button>
                    a href="update_show?id={{$v->id}}" rel="external nofollow" >修改/a>
                /td>
            /tr>
        @endforeach
    /table>
    @if ($errors->any())
        div class="alert alert-danger">
            ul>
                @foreach ($errors->all() as $error)
                    li>{{ $error }}/li>
                @endforeach
            /ul>
        /div>
    @endif

    {{$arr->appends(['user'=>$user])->links()}}
/div>

下面是jquery 關(guān)于無(wú)刷新刪除、批量、還有全選 我們使用的時(shí)候需要引用線(xiàn)上的jquery或者文件

因?yàn)榇a展示有問(wèn)題我們直接上圖

下面是修改操作 修改需要先查詢(xún)單條 然后根據(jù)id修改數(shù)據(jù)

@csrf
div style="width: 600px;height: auto;margin: 20px auto 0;">
    table>
        tr>
            td>
                用戶(hù)名:
            /td>
            td>
                input type="text" class="form-control" name="user" value="{{$arr['user']}}">
            /td>
        /tr>
        tr>
            td>
                昵稱(chēng):
            /td>
            td>
                input type="text" class="form-control" name="name" value="{{$arr['name']}}">
            /td>
        /tr>
        tr>
            td>
                密碼:
            /td>
            td>
                input type="password" class="form-control" name="password" value="{{$arr['password']}}">
            /td>
        /tr>
        tr>
            td>
                確認(rèn)密碼
            /td>
            td>
                input type="password" class="form-control" name="password2" value="{{$arr['password']}}">
            /td>
        /tr>
        tr>
            td>
                身份指定
            /td>
            td>
                select name="i_id" class="form-control">
                    @if($arr['i_id'] == 1)
                        option value="{{$arr['i_id']}}" selected>總長(zhǎng)/option>
                        option value="{{$arr['i_id']}}">副老大/option>
                        option value="{{$arr['i_id']}}">大隊(duì)長(zhǎng)/option>
                        option value="{{$arr['i_id']}}">小隊(duì)長(zhǎng)/option>
                        option value="{{$arr['i_id']}}">組長(zhǎng)/option>
                    @elseif($arr['i_id'] == 2)
                        option value="{{$arr['i_id']}}">總長(zhǎng)/option>
                        option value="{{$arr['i_id']}}" selected>副老大/option>
                        option value="{{$arr['i_id']}}">大隊(duì)長(zhǎng)/option>
                        option value="{{$arr['i_id']}}">小隊(duì)長(zhǎng)/option>
                        option value="{{$arr['i_id']}}">組長(zhǎng)/option>
                    @elseif($arr['i_id'] == 3)
                        option value="{{$arr['i_id']}}">總長(zhǎng)/option>
                        option value="{{$arr['i_id']}}">副老大/option>
                        option value="{{$arr['i_id']}}" selected>大隊(duì)長(zhǎng)/option>
                        option value="{{$arr['i_id']}}">小隊(duì)長(zhǎng)/option>
                        option value="{{$arr['i_id']}}">組長(zhǎng)/option>
                    @elseif($arr['i_id'] == 4)
                        option value="{{$arr['i_id']}}">總長(zhǎng)/option>
                        option value="{{$arr['i_id']}}">副老大/option>
                        option value="{{$arr['i_id']}}">大隊(duì)長(zhǎng)/option>
                        option value="{{$arr['i_id']}}" selected>小隊(duì)長(zhǎng)/option>
                        option value="{{$arr['i_id']}}">組長(zhǎng)/option>
                    @elseif($arr['i_id'] == 5)
                        option value="{{$arr['i_id']}}">總長(zhǎng)/option>
                        option value="{{$arr['i_id']}}">副老大/option>
                        option value="{{$arr['i_id']}}">大隊(duì)長(zhǎng)/option>
                        option value="{{$arr['i_id']}}">小隊(duì)長(zhǎng)/option>
                        option value="{{$arr['i_id']}}" selected>組長(zhǎng)/option>
                    @else
                        未知組
                        @endif
                /select>
            /td>
        /tr>
        tr>
            td>
                狀態(tài)
            /td>
            td>
                select name="status" class="form-control">
                        @if($arr['status'] == 0)
                        option value="{{$arr['status']}}" selected>啟用/option>
                        option value="{{$arr['status']}}">未啟用/option>
                    @elseif($arr['status'] == 1)
                        option value="{{$arr['status']}}">啟用/option>
                        option value="{{$arr['status']}}" selected>未啟用/option>
                        @endif
                /select>
            /td>
        /tr>
        tr>
            td>
                手機(jī)號(hào)
            /td>
            td>
                input type="text" class="form-control" name="tel" value="{{$arr['tel']}}">
            /td>

        /tr>
        tr>
            td>
                IP白名單1
            /td>
            td>
                input type="text" class="form-control" name="ip1" value="{{$arr['ip1']}}">
            /td>
        /tr>
        tr>
            td>
                IP白名單2
            /td>
            td>
                input type="text" class="form-control" name="ip2" value="{{$arr['ip2']}}">
            /td>
        /tr>
        tr>
            td>
                頭像上傳
            /td>
            td>
                input type="file" name="img">
            /td>
        /tr>
        tr>
            td>/td>
            td>
                button type="submit" class="btn btn-primary">修改/button>
                button class="btn btn-primary">
                    a href="show" rel="external nofollow"  rel="external nofollow"  style="text-decoration: none;color: white">取消修改/a>
                /button>
            /td>
        /tr>
    /table>
    input type="hidden" value="{{$arr['id']}}" name="id">
/div>

下面就是我們期待的控制器了
1.單條的無(wú)刷新刪除

2.批量無(wú)刷新刪除

3.修改控制器

4.修改的視圖

5.登錄控制器-我們使用了session記錄防止隨意登錄

6.展示視圖控制器–開(kāi)始判斷有沒(méi)有存在session 存在才能進(jìn)入展示

7.清除session——因?yàn)榫W(wǎng)頁(yè)無(wú)法自動(dòng)退出,所以我們加入了一個(gè)退出登錄的按鈕來(lái)清除session

8.添加表單的視圖-因?yàn)槲覀兊南吕枰h(huán)所以我們獲取了數(shù)據(jù)庫(kù)的數(shù)據(jù)

9.添加表單的控制器——我們使用了validate驗(yàn)證了一下 記得文件上傳需要前臺(tái)支持文件格式

好了,暫時(shí)只有那么多,本人只是個(gè)小菜鳥(niǎo),懂得不多,希望大牛們多加指點(diǎn)。

到此這篇關(guān)于laravel ajax curd 搜索登錄判斷功能的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)laravel ajax curd 搜索登錄內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • 淺談Laravel中使用Slack進(jìn)行異常通知
  • 如何用Laravel包含你自己的幫助函數(shù)
  • 詳解Laravel框架的依賴(lài)注入功能
  • php+laravel 掃碼二維碼簽到功能
  • laravel的數(shù)據(jù)表填充器使用詳解
  • Laravel中Kafka的使用詳解
  • laravel使用redis隊(duì)列實(shí)例講解
  • Laravel的加密解密與哈希實(shí)例講解
  • Laravel中10個(gè)有用的用法小結(jié)
  • 分析五個(gè)Laravel Dusk的使用技巧

標(biāo)簽:邯鄲 內(nèi)江 樂(lè)山 海南 黔東 德陽(yáng) 婁底 衡陽(yáng)

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《laravel ajax curd 搜索登錄判斷功能的實(shí)現(xiàn)》,本文關(guān)鍵詞  laravel,ajax,curd,搜索,登錄,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《laravel ajax curd 搜索登錄判斷功能的實(shí)現(xiàn)》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于laravel ajax curd 搜索登錄判斷功能的實(shí)現(xiàn)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    鹤庆县| 祁阳县| 铜陵市| 海晏县| 开原市| 永定县| 项城市| 溧阳市| 东光县| 宜川县| 新化县| 浙江省| 香港 | 滨海县| 钦州市| 昌平区| 哈巴河县| 山阳县| 房产| 花莲市| 行唐县| 明光市| 宁阳县| 泰和县| 辽宁省| 基隆市| 巴南区| 舞钢市| 宁城县| 阿荣旗| 鲁甸县| 内乡县| 怀宁县| 贡嘎县| 万年县| 泽州县| 界首市| 双峰县| 彝良县| 天祝| 辉县市|