salah dalam routing laravel 5.5 + ajax

Sorry gan, mau tanya saya soalnya route dalam laravel + ajax. ini errornya .

untuk routenya :

 <?php
Route::get('/', function () {
    return redirect('/home');
});

// Authentication Routes...
$this->get('login', 'Auth\LoginController@showLoginForm')->name('auth.login');
$this->post('login', 'Auth\LoginController@login')->name('auth.login');
$this->post('logout', 'Auth\LoginController@logout')->name('auth.logout');

// Registration Routes...
$this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('auth.register');
$this->post('register', 'Auth\RegisterController@register')->name('auth.register');

// Password Reset Routes...
$this->get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('auth.password.reset');
$this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('auth.password.reset');
$this->get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('auth.password.email');
$this->post('password/reset', 'Auth\ResetPasswordController@reset')->name('auth.password.reset');

Route::group(['middleware' => 'auth'], function () {
    Route::get('/home', 'HomeController@index');

    Route::resource('divisis','DivisisController', ['except' => ['create']]);
    Route::get('table', 'DivisisController@get_tableDivisi');
    Route::redirect('/', '/divisis', 301);
});

ini controllernya :

 <?php

namespace App\Http\Controllers;

use App\Divisi;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Purifier;

class DivisisController extends Controller
{
    public function index()
    {
        $divisis = Divisi::orderBy('id', 'desc')->get();
        return view('divisis.index')->withDivisis($divisis);
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */

    public function get_tableDivisi()
    {
        $divisis = Divisi::orderBy('id', 'desc')->get();
        return view('divisis.table')->withDivisis($divisis);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */

    public function store(Request $request)
    {
        Validator::make($request->all(), [
            'kddivisi' => 'required|max:255',
            'nmdivisi' => 'required'
        ])->validate();

        $divisi = new Divisi();

        $divisi->kddivisi = Purifier::clean($request->kddivisi);
        $divisi->nmdivisi = $request->nmdivisi;


        $divisi->save();

        return response()->json([
            'status' => 'success',
            'msg' => 'New item has been saved'
        ]);
    }
    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $divisi = Divisi::find($id);
        return response()->json([
            'status'    => 'success',
            'id'        => $divisi->id,
            'kddivisi'  => $divisi->kddivisi,
            'nmdivisi'  => $divisi->nmdivisi,
        ]);
    }
    /** Update the specified resource in storage.
    *
    * @param  \Illuminate\Http\Request  $request
    * @param  int  $id
    * @return \Illuminate\Http\Response
    */
    public function update(Request $request, $id)
    {
        $divisi = Divisi::find($id);

        Validator::make($request->all(),[
            'kddivisi'  => 'required|max:255',
            'nmdivisi'  => 'required'
        ])->validate();

        $divisi->kddivisi = $request->divisi;
        $divisi->nmdivisi = Purifier::clean($request->divisi);

        $divisi->save();
    }
    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        $divisi = ToDoList::find($id);

        $divisi->delete();

        return response()->json([
            'status' => 'success',
            'msg' => 'item has been deleted'
        ]);
    }
}

ini modelnya :

 <?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Divisi extends Model
{

    protected $dates = ['created_at', 'updated_at','deleted_at'];
    protected $fillable = ['id','kddivisi','nmdivisi'];
    protected $table = 'divisis';


}

mohon bantuannya gan, saya parsing data json tp gk bisa edit salah di route tp saya masih kurang paham laravel. makasih banyak gan dan sekolah koding

avatar umaroliver7
@umaroliver7

17 Kontribusi 1 Poin

Dipost 6 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban