galih56

galih56

Member Since 2 Months Ago

Experience Points 640
Experience Level 1

4,360 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

23 May
1 day ago

galih56 started a new conversation Why My Autocomplete Doesn't Work? (can't Get Value From Json Data)

I'm working on autocomplete with jquery-ui.But this thing doesn't work properly.When i use console.log on the ajax.success,it shows the data.But when i use console.log on select property.It shows item:null

My autocomplete script

 $(document).ready(function(){
        
        $( ".search" ).autocomplete({
            source: function(request,response){ 
                $.ajax({
                    url:"{{ url('/search-pegawai') }}",
                    method: 'get',
                    data: { somefield: "Some field value", _token: '{{csrf_token()}}' },
                   success:function(data){
                       console.log(data);//data shows perfectly
                   }
                })
            },
            minLength: 5,
            select: function(event, ui) {
                event.preventDefault();
                $('.search').val(ui.item.nama);
                console.log(ui) //item :null
            },
            change:function(event,ui){
                console.log(ui);// item:null
            }
        }).bind('focus', function () {
            $('.ui-autocomplete').css('z-index','9999').css('overflow-y','scroll').css('max-height','300px');
        });
}
 public function loadData(Request $request)
    {
        $results = array();
        $data = Pegawai::select('nama', 'nip')->whereRaw("upper(nama) like upper('%" . $request->get('search') . "%')")->orWhere('nip', '=', $request->get('search'))->get();
        foreach ($data as $query) {
            $results[] = ['nip' => $query->nip, 'nama' => $query->nama];
        }
        if (count($results)) {

            return response()->json($results);
        } else {
            return ['nip' => '', 'nama' => 'Data tidak ditemukan'];
        }
    }

*this autocomplete is running with 2k data.is this good for this feature or should i choose another feature?? i used to make basic select input but the browser become laggy when i use basic select

07 May
2 weeks ago

galih56 left a reply on How To Parse Json Data And Implement Fullcalendar Correctly ?

sorry the url must be ttp://localhost/laravel/eruangrapat/e-ruangrapat/public/transaksi/15"

galih56 started a new conversation How To Parse Json Data And Implement Fullcalendar Correctly ?

I have project that supposed to display calendar with dynamic load events. I created method inside controller that can return view and jsonparsed dataat the same time.But the data is not encoded correctly.What do i miss??

the error handler shows me this error: htmlspecialchars() expects parameter 1 to be string, array given

and when i try to return jsonparsed data directly.It return this value : [{"judul_rapat":"Rapat Penyusunan Anggaran 2020","start":"2019-05-29 09:00:00","finish":"2019-05-29 12:00:00","url":"http://localhost/laravel/eruangrapat/e-ruangrapat/public/transaksi/15"}]

the url inside the json data is maybe the problem.Am i right?

how to fix this problem??

and also i want to know,is this step good to implement fullcalendar.io in laravel?

Method show from controller

public function show($id)
    {
        $rp = Transaksi::find($id);
        if ($rp == null) {
            return redirect('ruangrapat');
        }
        $t = Transaksi::whereRaw("upper(nip_pemesan) like upper('%" . Auth::user()->nip . "%')")->get();
        $n = Notulen::find($rp->id_notulen);
        $events = [];
        foreach ($t as $item) {
            $events[] = [
                'judul_rapat' => $item->judul_rapat,
                'start' => $item->start,
                'finish' => $item->finish,
                'url' => url('transaksi/' . $item->id),
            ];
        }
        $w = json_encode($events);
        // $event_list[] = Calendar::event($rp->judul_rapat, true, new \DateTime($rp->start), new \DateTime($rp->finish));
        // $calendar_details = Calendar::addEvents($event_list);
        return $w;
        return view('ajax-result.transaksi.show')->with(compact('rp', 'w', 'n'));
    }

"use strict";
    $('#calendar').fullCalendar({
        header: {
            left: 'prev',
            center: 'title',
            right: 'next'
        },
        defaultDate: '{{ $rp->start }}',
        eventLimit: true, // allow "more" link when too many events
        events:{{ json_decode($w) }}
    });

    // Previous month action
    $('#cal-prev').on('click',function(){
        $('#calendar').fullCalendar( 'prev' );
    });

    // Next month action
    $('#cal-next').on('click',function(){
        $('#calendar').fullCalendar( 'next' );
    });

    // Change to month view
    $('#change-view-month').on('click',function(){
        $('#calendar').fullCalendar('changeView', 'month');

        // safari fix
        $('#content .main').fadeOut(0, function() {
            setTimeout( function() {
                $('#content .main').css({'display':'table'});
            }, 0);
        });

    });

    // Change to week view
    $('#change-view-week').on('click',function(){
        $('#calendar').fullCalendar( 'changeView', 'agendaWeek');

        // safari fix
        $('#content .main').fadeOut(0, function() {
            setTimeout( function() {
                $('#content .main').css({'display':'table'});
            }, 0);
        });

    });

    // Change to day view
    $('#change-view-day').on('click',function(){
        $('#calendar').fullCalendar( 'changeView','agendaDay');

        // safari fix
        $('#content .main').fadeOut(0, function() {
            setTimeout( function() {
                $('#content .main').css({'display':'table'});
            }, 0);
        });

    });

    // Change to today view
    $('#change-view-today').on('click',function(){
        $('#calendar').fullCalendar('today');
    });

    /* initialize the external events
     -----------------------------------------------------------------*/
    $('#external-events .event-control').each(function() {

        // store data so the calendar knows to render an event upon drop
        $(this).data('event', {
            title: $.trim($(this).text()), // use the element's text as the event title
            stick: true // maintain when user navigates (see docs on the renderEvent method)
        });
    });

    $('#external-events .event-control .event-remove').on('click', function(){
        $(this).parent().remove();
    });

    // Submitting new event form
    $('#add-event').submit(function(e){
        e.preventDefault();
        var form = $(this);

        var newEvent = $('<div class="event-control p-10 mb-10">'+$('#event-title').val() +'<a class="pull-right text-muted event-remove"><i class="fa fa-trash-o"></i></a></div>');

        $('#external-events .event-control:last').after(newEvent);

        $('#external-events .event-control').each(function() {

            // store data so the calendar knows to render an event upon drop
            $(this).data('event', {
                title: $.trim($(this).text()), // use the element's text as the event title
                stick: true // maintain when user navigates (see docs on the renderEvent method)
            });

            // make the event draggable using jQuery UI
            $(this).draggable({
                zIndex: 999,
                revert: true,      // will cause the event to go back to its
                revertDuration: 0  //  original position after the drag
            });

        });

        $('#external-events .event-control .event-remove').on('click', function(){
            $(this).parent().remove();
        });

        form[0].reset();

        $('#cal-new-event').modal('hide');

    });

23 Apr
1 month ago

galih56 started a new conversation Why My Pagination Is Not Styled?

I make a view with a simple pagination.

 public function index()
    {
        $data = new Ruangrapat();
        $data = $data->paginate(7);
        return view('ajax-result.ruangrapat.index')->with('data', $data);
    }

The data will be displayed on a table and i use ->link for pagination buttons.But when i click 1 of them.The table will show the page but the page will be containing pure html without any css.How do i make the pagination show the page real time like ajax?

21 Apr
1 month ago

galih56 left a reply on My Ajax Keep Returning 419 And 500 Error Status

@SNAPEY - what's laravel log file? is that the same like using dd( )?

galih56 left a reply on My Ajax Keep Returning 419 And 500 Error Status

@CRONIX - it works like a charm,you answer my question step by step.it's helpful.Thank you sir.I take this as a best answer

galih56 started a new conversation My Ajax Keep Returning 419 And 500 Error Status

I'm making form that's called by ajax and trying to make the form can submit using ajax.This form is supposed to submit the data by through route('ruangrapat.store).But everytime i submit the form.It always return 419 status when i don't use csrf_token() in ajax and if i use the csrf_token() in ajax.It always return 500 internal error.Can someone help me to solve this problem.I've been reading almost every discussion that i found in internet but still no answer. Maybe i missed something important on my code.please review my code.

//ajax
$(document).ready(function(){
             $('#form-ruangrapat').on('submit',function(e){

            e.preventDefault();
             var formdata=$('#form-ruangrapat').serialize();//should i do this??
//if i should take the value of inputs 1 by 1,please show me the proper way

             var token="{!!csrf_token()!!}"
            $.ajax({ 
                url:"{{route('ruangrapat.store')}}",
                data: {formData:formdata,_token:token},
                type:'post',
                success:function(result){
                    $('#result').html(result);
                }
            });
        });
        });


//controller
public function store(Request $request)
    {
        $data = new Ruangrapat();
       ...
        $data->contact = $request->get('contact');
        $data->save();
        return view('ajax-result.ruangrapat.index')->with('status', 'Ruang rapat baru berhasil ditambahkan!');
//is this return value correct??

    }

//route
Route::resource('ruangrapat', 'RuangrapatController');

galih56 started a new conversation Raw Database Structure Vs Eloquent Relationship

If i have 2 tables,I want to make relationship between them and i only create foreign key column without signing it to become foreign key in database structure (could be from DBMS or migration by using ->foreign() method) and i only set the relationship between those 2 tables from model using

    public function role()
    {
        return $this->belongsTo('App\Model\Role', 'role_id');
    }

is this good for my laravel project??

19 Apr
1 month ago

galih56 left a reply on How To Join Table Using Eloquent?

@SNAPEY - Thanks for your advice,tinker is also new for me

galih56 left a reply on How To Join Table Using Eloquent?

@NAKOV - Sorry sir,That was my fault,i forgot to add data with the same id like role_id in user table.That's why i can't display the role's name.Your reply make me want to check my pgadmin and i realized i forgot to add my role table with the same id like role_id in users table.

Thanks for your advice

galih56 left a reply on How To Join Table Using Eloquent?

@NAKOV - Sorry sir,That was my fault,i forgot to add data with the same id like role_id in user table.That's why i can't display the role's name.

I asked question on this website 2 times and you gave your time to help me solve my problem 2 times in a row. Thank you sir

galih56 left a reply on How To Join Table Using Eloquent?

@NAKOV - I tried out Auth::user()->role->nama but it returns "Trying to get property 'nama' of non-object" error message

and i tried Auth::user()->role()->get() it returns empty array

it's weird,my login system is working correctly i can do dd(Auth::user()->username)

i assume there is something wrong on my eloquent.But i don't know what that is

18 Apr
1 month ago

galih56 left a reply on Auth::user() Returns Null Value

@JLRDW - I didn't know that was the problem,usually if i make website with native php.datatype of user's id must be not a big deal.I'm still wondering why should we care about datatype of id in authentication

galih56 started a new conversation How To Join Table Using Eloquent?

I want to join 2 tables.Users and Role. The table structure is Role table have many user but user only have 1 role i'm still confused how to display name of the role from the role table.

Model User

public function role()
    {
        return $this->belongsTo('App\Role');
    }

Model Role

  public function user()
    {
        return $this->hasMany('App\User'); //pake local_key kalo nama id usernya bukan ' id'
    }

in a page.blade.php i call Auth::user()->role()->nama

what am i wrong?? can someone correct me??

17 Apr
1 month ago

galih56 left a reply on Auth::user() Returns Null Value

@WILK_RANDALL - i tried to access the Auth session not just in the constructor,i also tried to access the session through index() in the HomeController but it return null value.

Fortunately i found a discussion about the same issue.The Auth::atempt works successfully but it return null in index().it make middleware block the controller.and then i found the problem was from the database.I changed the 'id' dolumn from bigincrement to string via migration.It make Auth can't read the table properly when i do login.So i decided to change it back from varchar to integer.And then the loginController works correctly

galih56 left a reply on Auth::user() Returns Null Value

@MUNAZZIL - it becomes undefined variable

galih56 left a reply on Auth::user() Returns Null Value

@NAKOV - i don't get the part "here the user should exist from the session" How to pass Auth::user() to the session? is that not an object??

galih56 started a new conversation Auth::user() Returns Null Value

0

I'm working on username authentication. I thought my LoginController is working perfectly.But when i go to the page and do login.The page will be stay on login page.I checked my code,when i use dd(Auth::user()) in my HomeController. it always return null value.

i read some discussion on stackoverflow.People said i have to use this in the loginController's constructor.

$this->middleare(function($request,$next){
    $this->user=Auth::user();
    return $next($request)
})

but it doesn't work in my project.

I'm sure the only reason why my login page cannot redirect to the next page is because the Auth::user() have null value.But i don't know how to fix that.

can someone help me??

LoginController.php

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use App\User;

use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Auth\Validator;

class LoginController extends Controller
{


    use AuthenticatesUsers;


    protected $redirectTo = '/index';

    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }

    protected function authenticated(Request $request)
    {
        if (Auth::attempt(['username' => $request['username'], 'password' => $request['password']])) {

            return redirect('/');
        }
    }
    public function username()
    {
        return 'username';
    }
    protected function validateLogin(Request $request)
    {
        /*$this->validate($request, [
            "user_name" => 'required', 'user_password' => 'required',
        ]);*/
        $messages = [
            'username.required' => 'Username harus diisi',
            'username.unique' => 'Username sudah ada',
            'password.required' => 'Tolong isi password terlebih dahulu',
            'password.min' => 'Password harus diisi minimal 6 karakter.'
        ];
        return $this->validate($request, [
            'username' => ['required', 'string', 'max:150'],
            'password' => ['required', 'string', 'min:6'],
        ], $messages);
    }
}

HomeController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class HomeController extends Controller
{

    public function __construct()
    {
        dd(Auth::user()); //this return false
        $this->middleware('auth');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index()
    {
        return view('home');
    }
}
16 Apr
1 month ago

galih56 left a reply on Why My Login Form Always Show "credential Doesn't Match" Error?

i have,you can see in the method username(), it returns 'user_name'.that's the name of attribute on users table.But it keeps showing "these credentials doesn't match" message.

galih56 left a reply on Why My Login Form Always Show "credential Doesn't Match" Error?

logincontroller

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use App\User;

use App\Http\Controllers\Auth\Validator;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/index';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }

    protected function authenticated(Request $request, $user)
    {
        $request->session()->flash('status', 'Selamat Datang, ' . $user->user_name);
        return redirect('index');
    }
    public function username()
    {
        return 'user_name';
    }
    protected function validateLogin(Request $request)
    {
        /*$this->validate($request, [
            "user_name" => 'required', 'user_password' => 'required',
        ]);*/
        $messages = [
            'user_name.required' => 'Username harus diisi',
            'user_name.unique' => 'Username sudah ada',
            'password.required' => 'password.request tes: ' . $request->password,
            'password.confirmed' => 'Password Tidak Sama, Silahkan Mengisi Password Ulang.',
            'password.min' => 'Password harus diisi minimal 6 karakter.'
        ];
        return $this->validate($request, [
            'user_name' => ['required', 'string', 'max:150'],
            'password' => ['required', 'string', 'min:6'],
        ], $messages);
    }
}

galih56 started a new conversation Why My Login Form Always Show "credential Doesn't Match" Error?

i have database that has users table.Inside of users table.there is user_name and user_password.I want to make login system using user_name.But i have problem.My login form always show "these credential doesn't match" error everytime i want to login.Can someone help me??

this is the registercontroller.php

<?php

namespace App\Http\Controllers\Auth;

use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;

class RegisterController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Register Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles the registration of new users as well as their
    | validation and creation. By default this controller uses a trait to
    | provide this functionality without requiring any additional code.
    |
    */

    use RegistersUsers;

    /**
     * Where to redirect users after registration.
     *
     * @var string
     */
    protected $redirectTo = '/index';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest');
    }

    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {
        $messages = [
            'user_name.required' => 'Username harus diisi',
            'user_name.unique' => 'Username sudah ada',
            'user_password.request' => 'Password harus diisi', 'user_password.confirmed' => 'Password Tidak Sama, Silahkan Mengisi Password Ulang.',
            'user_password.min' => 'Password harus diisi minimal 6 karakter.'
        ];
        return Validator::make($data, [
            'user_name' => ['required', 'string', 'max:150', 'unique:master_user'],
            'user_password' => ['required', 'string', 'min:6'],
        ], $messages);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return \App\User
     */
    protected function create(array $data)
    {
        return User::create([
            'user_id' => $data['user_name'],
            'user_name' => $data['user_name'],
            'user_eneble' => true,
            'user_level' => null,
            'remember_token' => null,
            'role_id' => (int)$data['role'],
            'user_password' => Hash::make($data['user_password']),
        ]);
    }
}

LoginController
12 Mar
2 months ago

galih56 left a reply on Why My Update & Insert Form Return Url+token Instead Of Insert/update Data

@STEREOH - wat?!,that's a simple stupidity :v

ok i already fix that typo.but i have another problem.

<table class="table">
    <thead>
        <tr>
            <th scope="col">Kode Urusan</th>
            <th scope="col">Nama Urusan</th>
        </tr>
    </thead>
    <tbody>
        @foreach($urusan as $data)
        <tr>
            <td  scope="row">{{$data->kode_urusan}}</td>
            <td  scope="row">{{$data->nama_urusan}}</td>
            <td  scope="row"><a href="{{route('urusan.update',$data->kode_urusan)}}" id="editurusan">Edit</a></td>
        </tr>
        
        @endforeach
    </tbody>
</table>

is the href="{{route('urusan.update',$data->kode_urusan)}}" part correct?? it always display 404 not found,when i click that anchor tag.

the url will be http://127.0.0.1:8000/urusan/1

is that a correct url to go through edit method in controller with Roure::resource()??

galih56 left a reply on Why My Update & Insert Form Return Url+token Instead Of Insert/update Data

<form action="POST" action="{{route('urusan.update',$urusan->kode_urusan)}}">
             {{ method_field("PUT") }}
       {{ csrf_field() }}
           <thead>
               <tr>
                   <td>Kode Urusan</td>
               <td><input type="text" name="kode" value="{{$urusan->kode_urusan}}"></td>
               </tr>
           </thead>
           <tbody>
               <tr>
                   <td>Nama Urusan</td>
                   <td><input type="text" name="nama" value="{{$urusan->nama_urusan}}"></td>
               </tr>
               <tr>
                   <td colspan="2" align="center"><input type="submit" name="submit" class="btn btn-primary" value="Update"></td>
               </tr>
           </tbody>

           </form>

       </table>

galih56 left a reply on Why My Update & Insert Form Return Url+token Instead Of Insert/update Data

             {{ method_field("PUT") }}
       {{ csrf_field() }}
           <thead>
               <tr>
                   <td>Kode Urusan</td>
               <td><input type="text" name="kode" value="{{$urusan->kode_urusan}}"></td>
               </tr>
           </thead>
           <tbody>
               <tr>
                   <td>Nama Urusan</td>
                   <td><input type="text" name="nama" value="{{$urusan->nama_urusan}}"></td>
               </tr>
               <tr>
                   <td colspan="2" align="center"><input type="submit" name="submit" class="btn btn-primary" value="Update"></td>
               </tr>
           </tbody>

           </form>

       </table>

galih56 left a reply on Why My Update & Insert Form Return Url+token Instead Of Insert/update Data

@STEREOH - i can't write it correctly,it automaticly disapear when i try to write html codes

galih56 left a reply on Why My Update & Insert Form Return Url+token Instead Of Insert/update Data

There is not edit/delete option,I try to open the same question properly again but it keep showing bad translation to code format.

i hope this reply can display the correct format

{{ csrf_field() }} Kode Urusan Nama Urusan

galih56 started a new conversation Why My Update & Insert Form Return Url+token Instead Of Insert/update Data

I'm working on simple crud in laravel.I already built Controller,form, and model.But everytime i click the submit input.They always return this url and show 404 not found error,instead of insert the data.Can someone help me to find the problem?i have no clue about this part.

http://127.0.0.1:8000/POST?_token=bD5c3O0XpfTX7NWL7RA7wXSw3rWrQ12fbGLMw0kf&kode=galih&nama=galih&submit=Submit[^]

I set the route using Route::resource('urusan','MasterUrusanController)

Insert Form

{{ csrf_field() }} Kode Urusan Nama Urusan

Update Form

{{ method_field("PUT") }} {{ csrf_field() }} Kode Urusan Nama Urusan
       </form>

   </table>

class MasterUrusanController extends Controller { public function index() { $urusan=MasterUrusan::all(); return view('master_urusan.select',['urusan'=>$urusan]); //return View::make('master_urusan.select')->with('urusan',$urusan); }

public function create()
{
    return view('master_urusan.insert') ;
}

public function store(Request $request)
{
    $data=new MasterUrusan();
    $data->nama = $request->get('kode');
    $data->nama = $request->get('nama');
    $data->save();
    return redirect('/urusan');
}

public function edit($kode_urusan)
{

    
    $data = MasterUrusan::where('kode_urusan','=',$kode_urusan)->firstOrFail();
    return view('master_urusan.update', ['urusan' => $data]);
}
public function update(Request $request,$kode_urusan)
{ 
    $data = MasterUrusan::where('kode_urusan','=',$kode_urusan)->firstOrFail();
    $data->nama = $request->get('nama');
    $data->save();
    return redirect('/urusan');
    
}

public function destroy($kode_urusan)
{
    $data = MasterUrusan::where('kode_urusan','=',$kode_urusan)->firstOrFail();
    $data->delete();
    return redirect('/urusan');
}

}

galih56 started a new conversation Why My Update & Insert Form Return Url+token Instead Of Insert/update Data

I'm working on simple crud in laravel.I already built Controller,form, and model.But everytime i click the submit input.They always return this url and show 404 not found error,instead of insert the data.Can someone help me to find the problem?i have no clue about this part.

http://127.0.0.1:8000/POST?_token=bD5c3O0XpfTX7NWL7RA7wXSw3rWrQ12fbGLMw0kf&kode=galih&nama=galih&submit=Submit[^]

I set the route using Route::resource('urusan','MasterUrusanController)

Insert Form

{{ csrf_field() }} Kode Urusan Nama Urusan

Insert Form

{{ method_field("PUT") }} {{ csrf_field() }} Kode Urusan Nama Urusan
       </form>

   </table>

Controller

class MasterUrusanController extends Controller { public function index() { $urusan=MasterUrusan::all(); return view('master_urusan.select',['urusan'=>$urusan]); //return View::make('master_urusan.select')->with('urusan',$urusan); }

public function create()
{
    return view('master_urusan.insert') ;
}

public function store(Request $request)
{
    $data=new MasterUrusan();
    $data->nama = $request->get('kode');
    $data->nama = $request->get('nama');
    $data->save();
    return redirect('/urusan');
}

public function edit($kode_urusan)
{

    
    $data = MasterUrusan::where('kode_urusan','=',$kode_urusan)->firstOrFail();
    return view('master_urusan.update', ['urusan' => $data]);
}
public function update(Request $request,$kode_urusan)
{ 
    $data = MasterUrusan::where('kode_urusan','=',$kode_urusan)->firstOrFail();
    $data->nama = $request->get('nama');
    $data->save();
    return redirect('/urusan');
    
}

public function destroy($kode_urusan)
{
    $data = MasterUrusan::where('kode_urusan','=',$kode_urusan)->firstOrFail();
    $data->delete();
    return redirect('/urusan');
}

}