HTML和LARAVEL:需要有关形式,模式和与数据库链接的帮助

问题描述 投票:0回答:2

我正在使用html / css / boostrap和Laravel开发网络门户。我必须在已经存在的页面(“选项”)上添加新功能,并在其中添加页眉选项和页面选项(Photo_1)。

在此页面上,我添加了一个“页脚选项”(Photo_2),该人可以修改Webportal的页脚并添加新的图标合作伙伴(Photo_3)。在我的选项页中,我使用@foreach查看具有创建的图标的表,该图标已经通过TableSeeder添加到SQLite数据库中(照片3:wp_footer_logos)。

要添加/编辑新的合作伙伴,我在表单中使用了模式,而删除合作伙伴也是同样的事情。

实际上,我可以创建一个新的合作伙伴,并将其添加到好的表wp_footer_logosPhoto_4)中。但是“新伙伴”也写在表wp_optionsPhoto_5)中,它们从“页眉选项和页面选项”中接收选项。

其他问题:

我无法删除伙伴(消息错误:无法加载资源:服务器以状态500(内部服务器错误)[http://127.0.0.1/admin/options/1]]响应

我无法编辑合作伙伴(消息错误:无法加载资源:服务器以405(状态为不允许的方法)[http://127.0.0.1/admin/options])作为响应。

顶部的提交按钮不保存修改,只有一个模式可以将所有内容保存在数据库中(消息错误:未能加载资源:服务器以405(方法不允许)状态响应[http://127.0.0.1/admin/options]) 。

您能帮我解决这些问题吗?如果有人来法国,这会更容易,但我也接受英语:)

Footer.php


namespace app;

use Illuminate\Database\Eloquent\Model;

Class FooterLogo extends Model
{
    protected $table = 'footer_logos';
    protected $primaryKey = 'c_pk_footer_logo_id';
    public $timestamps = false;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'footer_logo_name', 
        'footer_logo_thumb', 
        'footer_logo_URL', 
    ];}

OptionController.php

<?php

namespace App\Http\Controllers;

use App\Option;
use App\FooterLogo;
use App\Http\Requests\FooterLogoRequest;
use Illuminate\Http\Request;
use App\Rules\ColorRule;

class OptionController extends Controller
{

    public function __construct()
    {
        $this->middleware('auth');
        $this->authorizeResource(Option::class);
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $this->authorize('viewAny', \Auth::user());
        $options = array();
        foreach( Option::all() as $option ) {
            $options[$option->option_name] = $option->option_value;
        }
        $footer_logos = FooterLogo::all();

        return view('admin.options.index', ['options' => $options, 'footer_logos' => $footer_logos]);

    }

    /**
     * Store options in storage.
     *
     * @param  \App\FooterLogo $footer_logo
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $options = $request->all();
        unset($options['_token']);

        foreach($options as $option_name => $option_value ){
            if ($option_name=='background_color') {
                $request->background_color = $option_value;
                $this->validate($request, [
                    'background_color' => new ColorRule(),
                ]);
            }
        }

        foreach($options as $option_name => $option_value ){
            $option = Option::firstOrNew(['option_name' => $option_name]);
            $option->option_value = $option_value;
            $option->save();
        }

        $footer_logo = new FooterLogo([
        'footer_logo_name' => $request->get('footer_logo_name'),
        'footer_logo_URL' => $request->get('footer_logo_URL'),
        'footer_logo_thumb' => $request->get('footer_logo_thumb')
        ]);
        $footer_logo->save();

    return redirect('/admin/options')->with('success', 'New partner saved !');
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('admin.options');
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Option  $option
     * @return \Illuminate\Http\Response
     */
    public function show(Option $option)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\FooterLogo $footer_logo
     * @return \Illuminate\Http\Response
     */
    public function edit($c_pk_footer_logo_id)
    {
        $footer_logo = FooterLogo::find($c_pk_footer_logo_id);
        return view('admin.options.index', compact('footer_logo'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Http\Requests\FooterLogoRequest  $request
     * @param  \App\FooterLogo $footer_logo
     * @return \Illuminate\Http\Response
     */
    public function update(FooterLogoRequest $request, $c_pk_footer_logo_id)
    {
        $footer_logo = FooterLogo::find($c_pk_footer_logo_id);
        $footer_logo->footer_logo_name = $request->get('footer_logo_name');
        $footer_logo->footer_logo_URL = $request->get('footer_logo_URL');
        $footer_logo->footer_logo_thumb = $request->get('footer_logo_thumb');
        $footer_logo->save();

        return redirect('/admin/options')->with('success', 'Partner updated !');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param \App\FooterLogo $footer_logo
     * @return \Illuminate\Http\Response
     */
    public function destroy($c_pk_footer_logo_id)
    {
        $footer_logo = FooterLogo::find($c_pk_footer_logo_id);
        $footer_logo->delete();

        return redirect('/admin/options')->with('success','Partner deleted !');
    }
}

路线-Web.php

Route::resource('/admin/options', 'OptionController');
Route::get('/admin/options', 'OptionController@index')->name('admin.options.index');
Route::post('/admin/options', 'OptionController@store')->name('admin.options.store');

Route::put('/admin/options/footer', 'OptionController@update')->name('admin.options.update');
Route::delete('/admin/options/footer/{option}', 'OptionController@destroy')->name('admin.options.destroy');
Route::get('/admin/options/footer/{option}', 'OptionController@edit')->name('admin.options.edit');

查看-index.blade.php

@extends('adminlte::page')

@section('title', config('app.name', 'WebPortal').' : Global Options')

@section('content_header')
    <h1>Global Options</h1>
@stop

@section('content')

@inject('languages', 'App\Language')
@php ($background_color = \App\Option::getOption('background_color', '#333333'))

<form method="POST" action="/admin/options" >
    @csrf
<div class="form-group">
    <a role="button" href='/admin/content' class='btn btn-default' style="width:100px">To Content</a> </h3>
    <button type="submit" class="btn btn-primary pull-right" style="width:100px">Save</button>
</div>
<!-- HEADER OPTION -->
<div class="panel panel-default">
    // deleted to have the 30000 caracters ;)
</div>

<!-- PAGE OPTION -->
<div class="panel panel-default">

    <div class="panel-heading">    
        <label>Page Options</label>
    </div>

    <div class="panel-body">
        <div class='row'>
            <div class='col-md-4 col-md-offset-1'>
                <div class="form-group">
                    @php ($key = 'default_font')
                    <label>Default Font<br></label>
                    <select class="form-control select2" name='{{ $key }}' id="select_fontfamily">
                            <option value='{{ old($key) ?? (array_key_exists($key, $options) ? $options[$key] : '') }}' selected>{{ old($key) ?? (array_key_exists($key, $options) ? $options[$key] : '') }}</option>
                    </select>
                </div>

                <div class="form-group">
                    @php ($key = 'default_language')
                    <label>Default Language</label>
                    <select class="form-control select2" name='{{ $key }}'>
                        @foreach ( $languages::all() as $lang )
                            <option value='{{ $lang->c_pk_language_id }}' {{ (array_key_exists($key, $options) && $options[$key]==$lang->c_pk_language_id) ? 'selected' : '' }} >{{ $lang->language_name }}</option>
                        @endforeach
                    </select>
                </div>
            </div>

            <div class='col-md-4 col-md-offset-1'>
                <div class="form-group">
                    @php ($key = 'default_category_order')
                    <label>Default Category Order</label>
                    <select class="form-control select2" name='{{ $key }}'>
                        @foreach (array('Alfabetical','Date') as $sort_order)
                            <option value='{{ $sort_order }}' {{ (array_key_exists($key, $options) && $options[$key]==$sort_order) ? 'selected' : '' }} >{{ $sort_order }}</option>
                        @endforeach
                    </select>
                </div>

                <div class="form-group">
                    @php ($key = 'default_element_order')
                    <label>Default Element Order</label>
                    <select class="form-control select2" name='{{ $key }}'>
                        @foreach (array('Alfabetical','Date') as $sort_order)
                            <option value='{{ $sort_order }}' {{ (array_key_exists($key, $options) && $options[$key]==$sort_order) ? 'selected' : '' }} >{{ $sort_order }}</option>
                        @endforeach
                    </select>
                </div>

            </div>

        </div>
        <!-- /.row -->
    </div>
    <!-- /.panel-body -->
</div>

<!-- I ADD THIS PART-->
<!-- Footer Option-->
<div class="panel panel-default">
    <div class="row panel-heading" style="margin:0px;">    
        <label>Footer Options</label>
        <button style='margin-right:20px;' type="button" class="btn btn-primary pull-right btn-footer_logo-edit" 
        data-toggle="modal" data-target="#dlg-modal-edit" title="Add New Partner" data-id="" data-title=""><i class="fa fa-plus">Add Partner</i></button>
    </div>

    <div class="col-sm-8 col-sm-offset-2">
        @if(session()->get('success'))
            <div class="alert alert-success" style="margin-top:5px; text-align:center; font-weight:bold; font-size:large;">
                {{ session()->get('success') }}
            </div>
        @endif
    </div>

    <div class="panel-body">
        <div class='row'>
            <div class='row'>
                <div class='col-xs-12'>
                    <div class="box-header">
                    @include ('partials.errors')
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <table class="table table-bordered table-hover dataTable">
                            <thead>
                                <tr>
                                    <th class='col-sm-2 col-xs-5' style="text-align:center; vertical-align:middle; ">Partner Name</th>
                                    <th class='col-sm-4' style="text-align:center; vertical-align:middle;">URL Link</th>
                                    <th class='col-sm-4' style="text-align:center; vertical-align:middle;">Thumbnail Link</th>
                                    <th class='col-sm-1 col-xs-5' style="text-align:center; vertical-align:middle;">Icon</th>
                                    <th class='col-sm-1'> </th>
                                </tr>
                            </thead>

                            <tbody>
                                @foreach ($footer_logos as $footer_logo)
                                <tr>
                                    <td class='col-sm-2 col-xs-5' style="vertical-align:middle;"> {{ $footer_logo->footer_logo_name }}</td>
                                    <td class='col-sm-4' style="vertical-align:middle;"> <a href='{{ $footer_logo->footer_logo_URL }}' target="_blank" >{{ $footer_logo->footer_logo_URL }} </td>
                                    <td class='col-sm-4' style="vertical-align:middle;"> {{ $footer_logo->footer_logo_thumb }}</td>
                                    <td class='col-sm-1 col-xs-5' style="text-align:center; vertical-align:middle; background-color:#333333;"><img style=" max-height:50px; max-width:50px;" src="{{ $footer_logo->footer_logo_thumb }}" title="{{ $footer_logo->footer_logo_name }}" alt="{{ $footer_logo->footer_logo_name }}"></td>
                                    <td class='col-sm-1'>
                                        <div class='row' style="text-align:center;">
                                            @csrf
                                            <!-- EDIT AND DELETE BUTTONS -->
                                            <button type="button" class="btn btn-default btn-footer_logo-edit" title="Edit {{ $footer_logo->footer_logo_name }}" data-toggle="modal" data-target="#dlg-modal-edit" data-id="{{ $footer_logo->c_pk_footer_logo_id }}" data-title="{{ $footer_logo->footer_logo_name }}" ><i class="fa fa-edit"></i></button>
                                            <button type="button" class="btn btn-default btn-footer_logo-delete" title="Delete {{ $footer_logo->footer_logo_name }}" data-toggle="modal" data-target="#dlg-modal-delete" data-id="{{ $footer_logo->c_pk_footer_logo_id }}" ><i class="fa fa-trash" style="min-width:14px; min-height:14px;"></i></button>
                                        </div>
                                    </td>
                                </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                    <!-- /.box-body -->
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->

            <!-- Modal : EDIT PARTNER -->
            <div class="modal fade" id="dlg-modal-edit">
                <div class="modal-dialog">
                <div class="modal-content">
                <form method="POST" id="form-modal-edit" action="" >
                    @csrf
                    <input type="hidden" id="modal-edit-method" name="_method" value="put" />
                    <input type="hidden" id="modal-edit-id" name="c_pk_footer_logo_id" value="" />
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="modal-edit-title">Modify Icon Link</h4>
                    </div>
                    <div class="modal-body" id="modal-edit-body">
                        <div class="form-group">
                            <label for="title">Partner Name</label>
                            <input type="text" class="form-control" id="modal-footer_logo_name" name="footer_logo_name" value="{{ $footer_logo->footer_logo_name }}" required>
                        </div>
                        <div class="form-group">
                            <label for="title">Partner URL</label>
                            <input type="Link" class="form-control" id="modal-footer_logo_URL" name="footer_logo_URL" value="{{ $footer_logo->footer_logo_URL }}">
                        </div>
                        <div class="form-group">
                        @php ($key = 'footer_logo_thumb')
                            <label for="title">Partner Thumbnail Icon</label>
                            <div class="input-group">
                                <span class="input-group-btn">
                                    <a id="{{ $key }}" data-input="thumbnail-{{ $key }}" data-preview="holder-{{ $key }}" class="btn btn-primary" >
                                    <i class="fa fa-picture-o"></i> 
                                    </a>
                                </span>
                                <input type="link" class="form-control" id="thumbnail-{{ $key }}" name="{{ $key }}" value="{{ $footer_logo->footer_logo_thumb}}" required>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
                        <button id="btn-modal-edit" type="submit" class="btn btn-primary pull-right">Save</button>
                    </div>
                </form>
                </div>
                <!-- /.modal-content -->
                </div>
                <!-- /.modal-dialog -->
            </div>
            <!-- /.modal --> 

            <!-- Modal : DELETE PARTNER -->
            <div class="modal fade" id="dlg-modal-delete">
                <div class="modal-dialog">
                <div class="modal-content">
                    <form method="POST" id="form-modal-delete" action="" >
                        @csrf
                        @method('DELETE')
                        <input type="hidden" name="_method" value="delete" />
                        <input type="hidden" id="modal-delete-id" name="c_pk_footer_logo_id" value="" />
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="modal-delete-title">Delete Partner</h4>
                        </div>
                        <div class="modal-body" id="modal-delete-body">
                            <p>Are you sure you want to delete : {{ $footer_logo->footer_logo_name }} ? &hellip;</p>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
                            <button id="btn-modal-delete" type="submit" class="btn btn-primary pull-right">Delete</button>
                        </div>
                    </form>
                </div>
                <!-- /.modal-content -->
                </div>
                <!-- /.modal-dialog -->
            </div>
            <!-- /.modal --> 

        </div>
        <!-- /.row -->
    </div>  
    <!-- /.panel-body --> 
</div>
<!-- /.panel panel-default -->

</form>

@stop


@section('js')

<script src="/vendor/laravel-filemanager/js/lfm.js"></script>

<!-- Insert webfont directly into webportal application -->
<script src="https://ajax.googleapis.com/ajax/libs/webfont/1.5.18/webfont.js"></script>
<script src="/vendor/higooglefonts/fonts.js"></script>

<script>

    var options = {
        filebrowserImageBrowseUrl: '/laravel-filemanager?type=Images',
        filebrowserImageUploadUrl: '/laravel-filemanager/upload?type=Images&_token=',
        filebrowserBrowseUrl: '/laravel-filemanager?type=Files',
        filebrowserUploadUrl: '/laravel-filemanager/upload?type=Files&_token='
    };
    $('#background_image').filemanager('image');
    $('#main_icon').filemanager('image');
    $('#customer_icon').filemanager('image');
    $('#footer_logo_thumb').filemanager('image');


    $('#background_color_selected').on("change",()=>{
        var color = $('#background_color_selected').val();
        $('#background_color').val(color);
    });
    $('#background_color').on("change",()=>{
        var color = $('#background_color').val();
        $('#background_color_selected').val(color);
    });
    //$('#background_color').colorpicker({});

    $( "#select_fontfamily" ).higooglefonts({           
        selectedCallback:function(e){
            console.log(e);
        },
        loadedCallback:function(font){
            console.log(font);
            //$("#paragraph").css("font-family", font); // Change the font-family of the #paragraph
        }           
    }); 

</script>

<script> 
    $(function () {
        $('.dataTable').DataTable({
            'paging'      : true,
            'lengthChange': false,
            'searching'   : false,
            'ordering'    : true,
            'info'        : true,
            'autoWidth'   : false
        });

        $('.btn-footer_logo-delete').on('click', function(){
            // Delete
            $('#modal-action-title').text('Remove '+$(this).data('title'));
            $('#modal-action-body').html('Are you going to remove : <b>'+$(this).data('title')+'</b> ?');
            $('#modal-action-method').val('DELETE');
            $('#form-modal-delete').attr("action","/admin/options/"+$(this).data('id'));
            $('#dlg-modal-action').modal();
        });

        $('.btn-footer_logo-edit').on('click', function(){
            // Edit
            // VERIFIER A QUOI CORRESPOND LE 'id' dans le IF !!!!!!
            if ($(this).data('id')) {
                $('#form-modal-edit').attr("action","/admin/options/"+$(this).data('id'));
                $('#modal-edit-method').val('PUT');
                $('#modal-edit-id').val( $(this).data('id') );
                $('#modal-edit-title').text('Edit Partner');
                $('#modal-footer_log_name').val($(this).data('title'));
                $('#modal-footer_log_URL').val($(this).data('title'));
                $('#modal-footer_log_thumb').val($(this).data('title'));
            // Create
            } else {
                $('#form-modal-edit').attr("action","/admin/options");
                $('#modal-edit-method').val('POST');
                $('#modal-edit-id').val("");
                $('#modal-edit-title').text('Add Partner');
                $('#modal-footer_logo_name').val("");
                $('#modal-footer_logo_URL').val("");
                $('#modal-footer_logo_thumb').val("");
            };
            $('#dlg-modal-action').modal();
        });
    })  



</script>

@stop

请求-FooterLogoRequest.php

<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class FooterLogoRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'footer_logo_name' => ['required', 'string', 'max:100'],
            'footer_logo_thumb' => ['required', 'string', 'max:200'],
            'footer_logo_URL' => ['string', 'max:200']
        ];
    }
}
php jquery html laravel modal-dialog
2个回答
0
投票

您是否对管理服务器拥有任​​何权利,是否对网页文档本身赋予了相同的权利,这可能只是您的文档没有编辑或删除任何内容所需要的权限...这是我有时遇到的典型错误,如果我有文件,编辑其他文件,导致这些文件随后被视为程序,并且程序需要编辑删除等权限,那么您是否可以更改这些文件?权限

也许一些截图


0
投票

对不起我的英语,因为我是法国人,我不太擅长轻松解释我的需求。 (请不要编辑和删除这些单词!)

我修改了我的问题,然后我的一些问题消失了。

现在,当我要删除或更新时,它不起作用。我使用两种模式,仅使用ADD PARTNER工作,但不使用UPDATE和DELETE。

ROUTE:

Route::resource('/admin/footer_logo/', 'FooterLogoController');
Route::post('/admin/footer_logo/', 'FooterLogoController@storeFooter');
Route::put('/admin/footer_logo/{footer_logo}', 'FooterLogoController@update')->name('admin.options.update');
Route::delete('/admin/footer_logo/{footer_logo}', 'FooterLogoController@destroy')->name('admin.options.destroy');

MODALS:

<!-- Modal : ADD or UPDATE PARTNER -->
            <div class="modal fade" id="dlg-modal-edit">
                <div class="modal-dialog">
                <div class="modal-content">
                <form method="POST" id="form-modal-edit" action="" >
                    @csrf
                    <input type="hidden" id="modal-edit-method" name="_method" value="put"/>
                    <input type="hidden" id="modal-edit-id" name="c_pk_footer_logo_id" value="" />
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="modal-edit-title">Modify Icon Link</h4>
                    </div>
                    <div class="modal-body" id="modal-edit-body">
                        <div class="form-group">
                            <label for="title">Partner Name</label>
                            <input type="text" class="form-control" id="modal-footer_logo_name" name="footer_logo_name" value="{{ $footer_logo->footer_logo_name }}" required>
                        </div>
                        <div class="form-group">
                            <label for="title">Partner URL</label>
                            <input type="Link" class="form-control" id="modal-footer_logo_URL" name="footer_logo_URL" value="{{ $footer_logo->footer_logo_URL }}">
                        </div>
                        <div class="form-group">
                        @php ($key = 'footer_logo_thumb')
                            <label for="title">Partner Thumbnail Icon</label>
                            <div class="input-group">
                                <span class="input-group-btn">
                                    <a id="{{ $key }}" data-input="thumbnail-{{ $key }}" data-preview="holder-{{ $key }}" class="btn btn-primary" >
                                    <i class="fa fa-picture-o"></i> 
                                    </a>
                                </span>
                                <input type="link" class="form-control" id="thumbnail-{{ $key }}" name="{{ $key }}" value="{{ $footer_logo->footer_logo_thumb}}" required>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
                        <button id="btn-modal-edit" type="submit" class="btn btn-primary pull-right">Save</button>
                    </div>
                </form>
                </div>
                <!-- /.modal-content -->
                </div>
                <!-- /.modal-dialog -->
            </div>
            <!-- /.modal --> 

            <!-- Modal : DELETE PARTNER -->
            <div class="modal fade" id="dlg-modal-delete">
                <div class="modal-dialog">
                <div class="modal-content">
                    <form method="DELETE" id="form-modal-delete" action="/admin/footer_logo" >
                        @csrf
                        @method('DELETE')
                        <input type="hidden" name="_method" value="delete" />
                        <input type="hidden" id="modal-delete-id" name="c_pk_footer_logo_id" value="" />
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="modal-delete-title">Delete Partner</h4>
                        </div>
                        <div class="modal-body" id="modal-delete-body">
                            <p>Are you sure you want to delete : {{ $footer_logo->footer_logo_name }} ? &hellip;</p>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Close</button>
                            <button id="btn-modal-delete" type="submit" class="btn btn-primary pull-right">Delete</button>
                        </div>
                    </form>
                </div>
                <!-- /.modal-content -->
                </div>
                <!-- /.modal-dialog -->
            </div>
            <!-- /.modal --> 

JQuery for MODALS:

<script> 
    $(function () {
        $('.dataTable').DataTable({
            'paging'      : true,
            'lengthChange': false,
            'searching'   : false,
            'ordering'    : true,
            'info'        : true,
            'autoWidth'   : false
        });

        $('.btn-footer_logo-delete').on('click', function(){
            // Delete
            $('#form-modal-delete').attr("action","/admin/footer_logo/"+$(this).data('id'));
            $('#modal-action-method').val('DELETE');
            $('#modal-action-title').text('Remove '+$(this).data('title'));
            $('#modal-action-body').html('Are you going to remove : <b>'+$(this).data('title')+'</b> ?');
            $('#dlg-modal-action').modal();
        });

        $('.btn-footer_logo-edit').on('click', function(){
            // UPDATE
            if ($(this).data('id')) {
                $('#form-modal-edit').attr("action","/admin/footer_logo/"+$(this).data('id'));
                $('#modal-edit-method').val('PUT');
                $('#modal-edit-id').val( $(this).data('id') );
                $('#modal-edit-title').text('Edit Partner');
                $('#modal-footer_log_name').val($(this).data('title'));
                $('#modal-footer_log_URL').val($(this).data('title'));
                $('#modal-footer_log_thumb').val($(this).data('title'));
            // ADD
            } else {
                $('#form-modal-edit').attr("action","/admin/footer_logo");
                $('#modal-edit-method').val('POST');
                $('#modal-edit-id').val("");
                $('#modal-edit-title').text('Add Partner');
                $('#modal-footer_logo_name').val("");
                $('#modal-footer_logo_URL').val("");
                $('#modal-footer_logo_thumb').val("");
            }
           $('#dlg-modal-action').modal();
        });
    })  

</script>

FooterController:

<?php

namespace App\Http\Controllers;

use App\FooterLogo;
use App\Http\Requests\FooterLogoRequest;
use Illuminate\Http\Request;

class FooterLogoController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
        $this->authorizeResource(FooterLogo::class);
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {        
       //
    }

    /**
     * Store options in storage.
     *
     * @param  \App\FooterLogo $footer_logo
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function storeFooter(Request $request)
    {
        $footer_logo = new FooterLogo([
        'footer_logo_name' => $request->get('footer_logo_name'),
        'footer_logo_URL' => $request->get('footer_logo_URL'),
        'footer_logo_thumb' => $request->get('footer_logo_thumb')
        ]);
        $footer_logo->save();

    return redirect('/admin/options')->with('success', 'New partner saved !');
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('admin.options');
    }

    /**
     * Display the specified resource.
     *
     * @param  \App\FooterLogo  $footer_logo
     * @return \Illuminate\Http\Response
     */
    public function show(FooterLogo $footer_logo)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\FooterLogo $footer_logo
     * @return \Illuminate\Http\Response
     */
    public function edit($footer_logo)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Http\Requests\FooterLogoRequest $request
     * @param  \App\FooterLogo $footer_logo
     * @return \Illuminate\Http\Response
     */
    public function update(FooterLogoRequest $request, $c_pk_footer_logo_id)
    {
        $footer_logo = FooterLogo::find($request->c_pk_footer_logo_id);
        $footer_logo->c_pk_footer_logo_id = $request->get('c_pk_footer_logo_id');
        $footer_logo->footer_logo_name = $request->get('footer_logo_name');
        $footer_logo->footer_logo_URL = $request->get('footer_logo_URL');
        $footer_logo->footer_logo_thumb = $request->get('footer_logo_thumb');
        $footer_logo->save();

        return redirect('/admin/options')->with('success', 'Partner updated !');
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \Request $request
     * @param \App\FooterLogo $footer_logo
     * @return \Illuminate\Http\Response
     */
    public function destroy(Request $request, $c_pk_footer_logo_id)
    {
        $footer_logo = FooterLogo::find($request->$c_pk_footer_logo_id);
        $footer_logo->delete();

        return redirect('/admin/options')->with('success','Partner deleted !');
    }
}

有解决我问题的想法吗?

© www.soinside.com 2019 - 2024. All rights reserved.