galih56

galih56

Member Since 7 Months Ago

Experience Points
910
Total
Experience

4,090 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-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 1
910 XP
Sep
19
1 month ago
Activity icon

Replied to How To Make Parallax Animation?

oh sorry..the question is how to hide the decorations after i refresh the page?

Sep
18
1 month ago
Activity icon

Started a new conversation How To Make Parallax Animation?

I built my own web portfolio. It's not really responsive. The problem is i built some animations with javascript. The animations are supposed to disappear when we scroll to specific divs. The first time we load the page and scroll the page, the animation will disappear, but if we click the "about" button and then we refresh the page, the decorations will appear on the screen. It's really annoying for visitors.

the website: https://galih56.github.io/

The repo: https://github.com/galih56/galih56.github.io

Aug
31
1 month ago
Activity icon

Replied to Parallax Animation In Vanilla Javascript

sorry i forgot to give a response to you.That works exactly what i expected.Thanks sir.I didn't knw inline elemnt doesn't work with translate.How do you know that?

Aug
28
1 month ago
Activity icon

Started a new conversation Parallax Animation In Vanilla Javascript

I make some code to move some elements at the same time by scrolling the page.But there is only 1 element that can move.How do i fix this?

<body>
    <section class="greeting">
        <div class="greeting-text-1">
            <div>
                <span class="scroll" data-nama="tes"data-rateX="1" data-rateY="-1" data-direction="vertical"id="text-1-1">Hello</span>
                <span class="scroll"  data-rateX="1" data-rateY="-1" data-direction="vertical" id="text-1-2"> World.</span>
            </div>
        </div>
        <div class="greeting-text-2">
            <div>
                <span class="scroll" data-rateX="1" data-rateY="0" data-direction="horizontal"id="text-2-1">My Name is</span>
                <span class="scroll"  data-rateX="1" data-rateY="0"  data-direction="horizontal" id="text-2-2">GALIH INDRA...</span>
            </div>  
        </div>
    </section>
</body>
<script type="text/javascript">
    window.addEventListener('scroll',function(e){
        // const target =document.querySelector('.scroll');
        var target =document.querySelectorAll('.scroll');
        for (let i = 0; i < target.length; i++) {
            var posX=window.pageYOffset*target[i].dataset.ratex;
            var posY=window.pageYOffset*target[i].dataset.ratey;;
            //mengambil atribute data yang bernama rate (data-rate)

            if(target[i].dataset.direction==='vertical'){
                target[i].style.transform='translate3d(0px,'+posX+'px,0px';
            }
            if(target[i].dataset.direction==='horizontal'){
                 target[i].style.transform = 'translate3d('+posX+'px, '+posY+'px, 0px)';

            }
        }
    });
</script>
Aug
15
2 months ago
Activity icon

Started a new conversation How To Use Express-messages

I'm trying to make flash session with connect-flash in expressjs.I want to display the message in a pug file.But it's not working.I'm watching a video tutorial about this.

https://www.youtube.com/watch?v=rBzCvbA0Dls&list=PLillGF-RfqbYRpji8t4SxUkMxfowG4Kqp&index=8

this video released 2017,can someone help me to find the problem? is it about the lib version or i'm just missing something?

pug file

        .container
            if success //should i use this?
                include message

            //- != messages('message', locals)  or this?
                        
            block content
            br
            hr
            footer
            p Copyright &copy; 2017
        script(src='/bower_components/jquery/dist/jquery.js')  
        script(src='/bower_components/bootstrap/dist/js/bootstrap.js')
        script(src='/js/main.js')

app.js


const flash = require('connect-flash');
const session = require('express-session');

//Express session
app.use(session({
    secret: 'keyboard cat',
    resave: true,
    saveUninitialized: true,
    cookie: { secure: true }
}));

//Express messagees middleware
app.use(flash());
app.use(function (req, res, next) {
    res.locals.messages = require('express-messages')(req, res);
    next();
});


//store article
app.post('/article/add', function (req, res) {
    let article = new Article();
    article.title = req.body.title;
    article.body = req.body.body;
    article.author = req.body.author;
    article.save(function (err) {
        if (err) {
            console.log(err);
        } else {
            req.flash('success', 'Article Added');
            res.redirect('/');
        }
    });
});
Jun
04
4 months ago
Activity icon

Started a new conversation How To Solve "You May Need An Appropriate Loader To Handle This File Type" Error Message.

I build a simple app with angular8 and i got this error when i use a model to my component.ts.I don't know why this happen.Anyone can help me to solve this??I make all the classes without any error message.but when i run it on the browser.It shows

./src/app/test-form/test-form.component.ts 7:70
Module parse failed: Invalid number (7:70)
You may need an appropriate loader to handle this file type.
|     constructor() {
|         this.topics = ['Angular', 'React', 'Vue'];
>         this.userModel = new User('galih', '[email protected]', 082312514, '', 'morning', true);
|     }
|     ngOnInit() {

this is my component code

import { User } from '../model/user';

@Component({
  selector: 'app-test-form',
  templateUrl: './test-form.component.html',
  styleUrls: ['./test-form.component.css']
})

export class TestFormComponent implements OnInit {
  topics = ['Angular', 'React', 'Vue'];
  userModel = new User('galih', '[email protected]', 082312514, '', 'morning', true);
  constructor() { }

  ngOnInit() {
  }

}

Class User

export class User {
    constructor(
        public name: string,
        public email: string,
        public phone: number,
        public topic: string,
        public timePreference: string,
        public subscribe: boolean
    ) { }
}

html for the component

<div class="container-fluid col-6">
    <h3>Tes Form</h3>
    <form #userForm="ngForm">
        {{ userForm.value | json }} <br>User model : {{ userModel|json }}
        <!-- <div ngModelGroup="address">
            <div class="form-group">
                <label>City</label>
                <input type="text" required class="form-control" ngModel name="city">
                <small class="text-danger">Name is required</small>
            </div>

            <div class="form-group">
                <label> Street</label>
                <input type="text" class="form-control" ngModel name="street">
            </div>

        </div> -->
        <!-- Biar value setiam input bisa terbaca harus pake ngModel dan dikasih name -->
        <div class="form-group">
            <label>Name</label>
            <input type="text" required class="form-control" [(ngModel)]="userModel.name" name="name">
            <small class="text-danger">Name is required</small>
        </div>

        <div class="form-group">
            <label>Email</label>
            <input type="email" class="form-control" [(ngModel)]="userModel.email" name="email">
        
. . .
Jun
03
4 months ago
Activity icon

Started a new conversation How To Make Reports With DateTime Data?

Hello guys...I want to display some tables with some strings and dateTime data.This table will be displayed day/week/year.I've used fullcalendar.io for the front end website.But i think it will be not good looking if i just print the page or convert the page to pdf.Any advice for me??

May
23
4 months ago
Activity icon

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');
        });
}

Controller

 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

May
07
5 months ago
Activity icon

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

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 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');

    });

Apr
23
5 months ago
Activity icon

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?

Apr
21
5 months ago
Activity icon

Replied to My Ajax Keep Returning 419 And 500 Error Status

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

Activity icon

Replied to 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

Activity icon

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 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');
Activity icon

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??

Apr
19
6 months ago
Activity icon

Replied to How To Join Table Using Eloquent?

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

Activity icon

Replied to 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

Activity icon

Replied to 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

here my models

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;


class Role extends Model
{

    protected $table = "role";
    public $timestamps = false;
    protected $primaryKey = "id";
    protected $fillable = [
        'id', 'nama'

    ];

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


class User extends Authenticatable
{
    use Notifiable;


    protected $table = "user_eruangrapat";
    public $timestamps = false;
    protected $primaryKey = "id";

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'id', 'username', 'password', 'role_id'

    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password'
    ];

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

do i miss something??

Apr
18
6 months ago
Activity icon

Replied to 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

Activity icon

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??

Apr
17
6 months ago
Activity icon

Replied to 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

Activity icon

Replied to Auth::user() Returns Null Value

@MUNAZZIL - it becomes undefined variable

Activity icon

Replied to 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??

Activity icon

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');
    }
}
Apr
16
6 months ago
Activity icon

Replied to 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.

Activity icon

Replied to 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);
    }
}

Activity icon

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
Mar
12
7 months ago
Activity icon

Replied to 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()??

Activity icon

Replied to 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>

Activity icon

Replied to 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

Activity icon

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');
}

}

Activity icon

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');
}

}