Created
August 3, 2018 12:04
-
-
Save kresnasatya/bff09083f380bae5a7ad723b8ebc908b to your computer and use it in GitHub Desktop.
Bad Code (need improve)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controller; | |
use Illuminate\Http\Request; | |
use Auth; | |
// Nama class tidak StudlyCaps dan tanda kurung kurawal tidak dipisah setelah kata controller | |
class logincontroller extends Controller{ | |
// Nama fungsi tidak camelCase dan tanda kurung kurawal tidak dipisah setelah nama fungsi | |
public function login_form(){ | |
return view('login'); | |
} | |
public function login(Request $request){ | |
// Semestinya diberi jarak pemisah antara nama variable dan tanda sama dengan | |
$username=$request->input('username'); | |
$password = $request->input('password'); | |
// Semestinya diberi jarak pemisah setelah memberikan tanda koma di username | |
// dan jarak antara penutup tanda kurung dan tanda kurung kurawal | |
if(Auth::attempt($username,$password)){ | |
return view('home'); | |
}else{ // Semestinya diberi jarak pemisah antara kata "else" dan tanda kurung kurawal | |
// Penamaan variable yang tidak benar dan tidak manusiawi | |
$anu = json_encode('status' => false, 'message' => 'Username dan password salah.'); | |
} | |
} | |
// Tidak boleh ada baris kosong jika tidak ada fungsi yang dibuat. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment