Listing Program

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 59

LISTING PROGRAM

.env

APP_NAME=Laravel

APP_ENV=local

APP_KEY=base64:QxiaQGCDmIVmjxM8oqjJDcB268rvukB4e89ZS6vrSzU=

APP_DEBUG=true

APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql

DB_HOST=127.0.0.1

DB_PORT=3306

DB_DATABASE=db_sevteen

DB_USERNAME=root

DB_PASSWORD=

BROADCAST_DRIVER=log

CACHE_DRIVER=file

SESSION_DRIVER=file

SESSION_LIFETIME=120

QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null

REDIS_PORT=6379

MAIL_DRIVER=smtp

MAIL_HOST=smtp.mailtrap.io

MAIL_PORT=2525

MAIL_USERNAME=null

MAIL_PASSWORD=null

MAIL_ENCRYPTION=null

PUSHER_APP_ID=

PUSHER_APP_KEY=

PUSHER_APP_SECRET=

PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"

MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

Halaman Welcome

<!doctype html>

<html lang="{{ app()->getLocale() }}">

<head>

<meta charset="utf-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1">


<title>E-17</title>

<!-- Fonts -->

<link href="https://fonts.googleapis.com/css?family=Raleway:100,600"
rel="stylesheet" type="text/css">

<!-- Styles -->

<style>

html, body {

background-image: url("img/bgpolos.jpg");

background-color: #fff;

color: #636b6f;

font-family: "Colonna MT", sans-serif;

font-weight: 100;

height: 100vh;

margin: 0;

.full-height {

height: 100vh;

.flex-center {
align-items: center;

display: flex;

justify-content: center;

.position-ref {

position: relative;

.top-right {

position: absolute;

right: 10px;

top: 18px;

.content {

text-align: center;

.title {

font-size: 84px;

.links > a {

color: red ;

padding: 0 25px;
font-size: 24px;

font-weight: 600;

letter-spacing: .1rem;

text-decoration: none;

text-transform: uppercase;

.m-b-md {

margin-bottom: 30px;

</style>

</head>

<body>

<div class="flex-center position-ref full-height">

@if (Route::has('login'))

<div class="top-right links">

@auth

<a href="{{ url('/home') }}" ><img src="img/logo.png"


width="50"></a>

@else

<a href="{{ route('login') }}"> <!--Login--> </a>

<a href="{{ route('register') }}"> <!--Register--> </a>


@endauth

</div>

@endif

<div class="content" style="color:black">

</style>

<div class="title m-b-md">

WELCOME to E-17

</div>

<div style="background-color: red"><a style="color: white">klik


disini untuk</a></div>

<div class="links" style="background-color: white">

<a href="{{ route('login') }}">[--Login--]</a>

<!--<a href="https://laracasts.com">Beranda</a>

<a href="https://laravel-news.com">News</a>

<a href="https://forge.laravel.com">Forge</a>

<a href="https://github.com/laravel/laravel">GitHub</a>-->

</div>

</div>

</div>

</body>

</html>
Halaman Login

@extends('layouts.app')

@section('content')

<div class="container">

<div class="row justify-content-center">

<div class="col-md-8">

<div class="card">

<center><div style="background-color: #cccccc" class="card-


header"><img src="img/logo.png" width="100"></div></center>

<div class="card-body" style="background-color: #0033cc">

<form method="POST" action="{{ route('login') }}" aria-


label="{{ __('Login') }}">

@csrf

<div class="form-group row">

<label style="color: white" for="user_id" class="col-sm-4 col-


form-label text-md-right">{{ __('Masukkan Id') }}</label>

<div class="col-md-6">
<input id="user_id" type="numeric" class="form-
control{{ $errors->has('user_id') ? ' is-invalid' : '' }}" name="user_id"
value="{{ old('user_id') }}" required autofocus>

@if ($errors->has('user_id'))

<span class="invalid-feedback" role="alert">

<strong>{{ $errors->first('user_id') }}</strong>

</span>

@endif

</div>

</div>

<div class="form-group row">

<label style="color: white" for="password" class="col-md-4 col-


form-label text-md-right">{{ __('Password') }}</label>

<div class="col-md-6" >

<input id="password" type="password" class="form-


control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password"
required>

@if ($errors->has('password'))

<span class="invalid-feedback" role="alert">


<strong>{{ $errors->first('password') }}</strong>

</span>

@endif

</div>

</div>

<div class="form-group row">

<div class="col-md-6 offset-md-4">

<div class="form-check">

<input class="form-check-input" type="checkbox"


name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>

<label style="color: white" class="form-check-label"


for="remember">

{{ __('Remember Me') }}

</label>

</div>

</div>

</div>

<div class="form-group row mb-0">

<div class="col-md-8 offset-md-4">


<button type="submit" class="btn btn-primary"
style="background-color: #0099ff">

{{ __('Login') }}

</button>

<a style="color: white" class="btn btn-link"


href="{{ route('password.request') }}">

{{ __('Forgot Your Password?') }}

</a>

</div>

</div>

</form>

</div>

</div>

</div>

</div>

</div>

@endsection

Login controller

<?php

namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;

use Illuminate\Foundation\Auth\AuthenticatesUsers;

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 = '/home';

/**

* Create a new controller instance.

* @return void

*/

public function __construct()

$this->middleware('guest')->except('logout');

Halaman Home/Dashboard

@extends('layouts.app')

@section('content')

<div class="container">

<div class="row justify-content-center">

<div class="col-md-8">
<div class="card">

<center><div class="card-header"><img src="img/logos.jpeg"


width="100"></div></center>

<center><div class="card-body" style="background-color: #0033cc">

@if (session('status'))

<div class="alert alert-success" role="alert">

{{ session('status') }}

</div>

@endif

<a style="color: white"> Anda Berhasil Login</a>

</div></center>

</div>

</div>

</div>

</div>

@endsection

Home Controller

<?php

namespace App\Http\Controllers;
use Illuminate\Http\Request;

class HomeController extends Controller

/**

* Create a new controller instance.

* @return void

*/

public function __construct()

$this->middleware('auth');

/**

* Show the application dashboard.

* @return \Illuminate\Http\Response

*/

public function index()


{

return view('home');

Model User

<?php

namespace App;

use Illuminate\Notifications\Notifiable;

use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable

use Notifiable;

/**

* The attributes that are mass assignable.

* @var array

*/
protected $fillable = [

'name', 'user_id', 'password', 'admin',

];

/**

* The attributes that should be hidden for arrays.

* @var array

*/

protected $hidden = [

'password', 'remember_token',

];

Model Tendik, Siswa, dan Materi

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Tendik extends Model

{
protected $guarded = [];

Middleware IsAdmin Untuk Auth User 1 Tabel

<?php

namespace App\Http\Middleware;

use Closure;

class IsAdmin

/**

* Handle an incoming request.

* @param \Illuminate\Http\Request $request

* @param \Closure $next

* @return mixed

*/

public function handle($request, Closure $next)

if (auth()->check() && $request->user()->admin == 0) {


return $next($request);

return redirect()->guest('/');

Kernel untuk set middleware

<?php

namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel

/**

* The application's global HTTP middleware stack.

* These middleware are run during every request to your application.

* @var array

*/
protected $middleware = [

\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,

\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,

\App\Http\Middleware\TrimStrings::class,

\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,

\App\Http\Middleware\TrustProxies::class,

];

/**

* The application's route middleware groups.

* @var array

*/

protected $middlewareGroups = [

'web' => [

\App\Http\Middleware\EncryptCookies::class,

\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,

\Illuminate\Session\Middleware\StartSession::class,

// \Illuminate\Session\Middleware\AuthenticateSession::class,

\Illuminate\View\Middleware\ShareErrorsFromSession::class,

\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,

],

'api' => [

'throttle:60,1',

'bindings',

],

];

/**

* The application's route middleware.

* These middleware may be assigned to groups or used individually.

* @var array

*/

protected $routeMiddleware = [

'auth' => \Illuminate\Auth\Middleware\Authenticate::class,

'auth.basic' => \Illuminate\Auth\Middleware\


AuthenticateWithBasicAuth::class,

'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,


'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,

'can' => \Illuminate\Auth\Middleware\Authorize::class,

'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,

'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,

'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,

'admin' => \App\Http\Middleware\IsAdmin::class,

];

Controller

<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;

use Illuminate\Routing\Controller as BaseController;

use Illuminate\Foundation\Validation\ValidatesRequests;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class Controller extends BaseController

use AuthorizesRequests, DispatchesJobs, ValidatesRequests;


}

Routes (web.php)

<?php

/*

|--------------------------------------------------------------------------

| Web Routes

|--------------------------------------------------------------------------

| Here is where you can register web routes for your application. These

| routes are loaded by the RouteServiceProvider within a group which

| contains the "web" middleware group. Now create something great!

*/

Route::get('/', function () {

return view('welcome');

});

Route::prefix('admin')->middleware('auth')->group(function(){

//tendik

Route::get('tendik','TendikController@index');
Route::get('tendik/tambah','TendikController@tambah');

Route::post('tendik/simpan','TendikController@simpan');

Route::get('tendik/hapus/{id}', 'TendikController@hapus');

Route::get('tendik/edit/{id}','TendikController@edit');

Route::put('tendik/update/{id}','TendikController@update');

//siswa

Route::get('murid','MuridController@index');

Route::get('murid/tambah','MuridController@tambah');

Route::post('murid/simpan','MuridController@simpan');

Route::get('murid/hapus/{id}', 'MuridController@hapus');

Route::get('murid/edit/{id}','MuridController@edit');

Route::put('murid/update/{id}','MuridController@update');

//materi

Route::get('materi','MateriController@index');

Route::get('materi/tambah','MateriController@tambah');

Route::post('materi/simpan','MateriController@simpan');

Route::get('materi/hapus/{id}', 'MateriController@hapus');

Route::get('materi/edit/{id}','MateriController@edit');

Route::put('materi/update/{id}','MateriController@update');
//GURU//---------------------------------------------------------------------------------

Route::get('tendik1','Tendik1Controller@index');

Route::get('murid1','Murid1Controller@index');

Route::get('mapel1','Mapel1Controller@index');

Route::get('materi1','Materi1Controller@index');

Route::get('materi1/tambah','Materi1Controller@tambah');

Route::post('materi1/simpan','Materi1Controller@simpan');

Route::get('materi1/hapus/{id}', 'MateriController@hapus');

Route::get('materi1/edit/{id}','Materi1Controller@edit');

Route::put('materi1/update/{id}','Materi1Controller@update');

//MURID//---------------------------------------------------------------------------------

Route::get('tendik1','Tendik1Controller@index');

Route::get('murid1','Murid1Controller@index');

Route::get('mapel1','Mapel1Controller@index');

Route::get('materi2','Materi2Controller@index');

Route::get('materi2/download/{path}', 'Materi2Contoller@show');

});

Route::get('/beranda', 'BerandaController@fungsi1');

Auth::routes();

Route::get('/home', 'HomeController@index')->name('home');
Tampilan Layouts Dan Sekaligus Authentication Untuk User
(app.blade.php)

<!DOCTYPE html>

<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">

<style type="text/css"></style>

<head>

<link rel="stylesheet" type="text/css" href="css\bootstrap.app">

<meta charset="utf-8">

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- CSRF Token -->

<meta name="csrf-token" content="{{ csrf_token() }}">

<title> E-17 </title>

<!-- Scripts -->

<script src="{{ asset('js/app.js') }}" defer></script>

<!-- Fonts -->

<link rel="dns-prefetch" href="https://fonts.gstatic.com">


<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet"
type="text/css">

<!-- Styles -->

<link href="{{ asset('css/app.css') }}" rel="stylesheet">

</head>

<body>

</style>

<div id="app">

<nav style="background-color: #99ffff" class="navbar navbar-expand-md


navbar-light navbar-laravel">

<div class="container">

<a style="font-family: Gabriola" class="navbar-brand"


href="{{ url('/') }}">

<th>WELCOME</th>

</a>

<button class="navbar-toggler" type="button" data-toggle="collapse"


data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="{{ __('Toggle navigation') }}">

<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarSupportedContent">

<!-- Left Side Of Navbar -->

<ul class="navbar-nav mr-auto">

@auth

@if (Auth::user()->admin == 0)

</li>&nbsp; &nbsp; &nbsp;

<li class="dropdown">

<a href="#" class="dropdown-toggle" data-toggle="dropdown"


role="button" style="color: black">

Data Guru <span class="caret"></span>

</a>

<ul class="dropdown-menu" role="menu">

<li><a href="{{ url('admin/tendik') }}"><center>Data


Guru</center></a></li>

<li><a href="{{
url('admin/tendik/tambah') }}"><center>Tambah Guru</center></a></li>

</ul>

</li>&nbsp; &nbsp; &nbsp;

<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"
role="button" style="color: black">

Data Siswa <span class="caret"></span>

</a>

<ul class="dropdown-menu" role="menu">

<li><a href="{{ url('admin/murid') }}"><center>Data


Siswa</center></a></li>

<li><a href="{{
url('admin/murid/tambah') }}"><center>Tambah Siswa</center></a></li>

</ul>

</li>&nbsp; &nbsp; &nbsp;

<li class="dropdown">

<a href="#" class="dropdown-toggle" data-toggle="dropdown"


role="button" style="color: black">

Data Materi <span class="caret"></span>

</a>

<ul class="dropdown-menu" role="menu">

<li><a href="{{ url('admin/materi') }}"><center>Data


Materi</center></a></li>

<li><a href="{{
url('admin/materi/tambah') }}"><center>Tambah Materi</center></a></li>

</ul>

</li>&nbsp; &nbsp; &nbsp;


@elseif (Auth::user()->admin == 1)

<ul class="nav" role="menu">

<li><a href="{{ url('admin/tendik1') }}"><center>Data


Guru</center></a></li>&nbsp; &nbsp; &nbsp;

<li><a href="{{ url('admin/murid1') }}"><center>Data


Siswa</center></a></li>&nbsp; &nbsp; &nbsp;

<li><a href="{{ url('admin/materi1') }}"><center>Data


Materi</center></a></li>

</ul>

</li>

</ul>

@elseif (Auth::user()->admin == 2)

<ul class="nav" role="menu">

<li><a style="color: red" href="{{


url('admin/tendik1') }}"><center>Data Guru</center></a></li>&nbsp; &nbsp;
&nbsp;

<li><a style="color: red" href="{{


url('admin/murid1') }}"><center>Data Siswa</center></a></li>&nbsp; &nbsp;
&nbsp;

<li><a style="color: red" href="{{


url('admin/materi2') }}"><center>Data Materi</center></a></li>

</ul>

@endif

@endauth
</ul>

<!-- Right Side Of Navbar -->

<ul class="navbar-nav ml-auto">

<!-- Authentication Links -->

@guest

<!-- Login dan Regis Route

<li class="nav-item">

<a class="nav-link" href="{{ route('login') }}">{{ __('Login


') }}</a>

</li>

<li class="nav-item">

<a class="nav-link"
href="{{ route('register') }}">{{ __('Register') }}</a>

</li> -->

@else

<li class="nav-item dropdown">

<a id="navbarDropdown" class="nav-link dropdown-toggle"


href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-
expanded="false" v-pre>

{{ Auth::user()->name }} <span class="caret"></span>

</a>

<div>
<a class="dropdown-menu" href="{{ route('logout') }}"

onclick="event.preventDefault();

document.getElementById('logout-
form').submit();"><center>

{{ __('Logout') }}</center>

</a>

<form id="logout-form" action="{{ route('logout') }}"


method="POST" style="display: none;">

@csrf

</form>

</div>

</li>

</ul>

@endguest

</ul>

</div>

</div>

</nav>

<main class="py-4">

@if(Session::has('pesan'))

<div class="alert alert-info alert-dismissible">

<a href="#" class="close" data-dismiss="alert">&times;</a>


{{ Session::get('pesan') }}

</div>

@endif

@yield('content')

</main>

</div>

</body>

</html>

Halaman Data Guru Admin

@extends('layouts.app')

@section('content')

<div class="container">

<div class="row justify-content-center">

<div class="col-md-16">

<div class="card">

<div class="card-header">DATA {{ $judul }}</div>

<div class="card-body">

<table width="1170" border="2">

<thead>

<tr>
<th><center>NO</center></th>

<th><center>NAMA</center></th>

<th><center>Jenis Kelamin</center></th>

<th><center>Mata Pelajaran</center></th>

<th><center>NIK</center></th>

<th><center>NIP</center></th>

<th><center>NUPT</center></th>

<th><center>JABATAN</center></th>

<th><center>STATUS</center></th>

<th><center>Tanggal Lahir</center></th>

</tr>

</thead>

<tbody>

@foreach ($tendiks as $tendik)

<tr>

<td><center>{{ $loop->iteration }}</center></td>

<td><center>{{ $tendik->nama }}</center></td>

<td><center>{{ $tendik->jenkel }}</center></td>

<td><center>{{ $tendik->mapel }}</center></td>

<td><center>{{ $tendik->nik }}</center></td>

<td><center>{{ $tendik->nip }}</center></td>


<td><center>{{ $tendik->nupt }}</center></td>

<td><center>{{ $tendik->jabatan }}</center></td>

<td><center>{{ $tendik->status }}</center></td>

<td><center>{{ $tendik->tgl_lahir }}</center></td>

<td><center>

<a href="{{ url('admin/tendik/edit/'.$tendik->id) }}" class="btn btn-


info" > Ubah</a>

&nbsp;

<a href="{{ url('admin/tendik/hapus/'.$tendik->id) }}" class="btn


btn-danger" onclick="return confirm('Anda yakin?')" > Hapus </a>

</td></center>

</tr>

@endforeach

</tbody>

</table>

{{ $tendiks->links() }}

</div>

</div>
</div>

</div>

</div>

@endsection

Halaman Tambah Data Guru

@extends('layouts.app')

@section('content')

<div class="container">

<div class="row justify-content-center">

<div class="col-md-8">

<div class="card">

<div class="card-header">TAMBAH TENDIK</div>

<div class="card-body">

{{{ Form::model($tendik, array('action' => $action, 'files' => true,


'method' => $method)) }}}

<div class="form-group">

{{ Form::label('nama', 'NAMA') }}

{{ Form::text('nama',null,array('class'=>'form-
control','placeholder' => 'Masukkan Nama','autofocus')) }}

<span class="text-danger">{{ $errors->first('nama') }}</span>

</div>
<div class="form-group">

{{ Form::label('Jenis Kelamin', 'Jenis Kelamin') }}

<br>

{{ Form::radio('jenkel', 'L', true)}} Laki-Laki

{{ Form::radio('jenkel', 'P', false)}} Perempuan

<span class="text-danger">{{ $errors->first('jenkel') }}</span>

</div>

<div class="form-group">

{{ Form::label('mapel', 'Mata Pelajaran') }}

{{ Form::text('mapel',null,array('class'=>'form-
control','placeholder' => 'Mata Pelajaran','autofocus')) }}

<span class="text-danger">{{ $errors->first('mapel') }}</span>

</div>

<div class="form-group">

{{ Form::label('nik', 'Nik') }}

{{ Form::text('nik',null,array('class'=>'form-control','placeholder'
=> 'Masukkan Nik','autofocus')) }}

<span class="text-danger">{{ $errors->first('nik') }}</span>

</div>

<div class="form-group">

{{ Form::label('nip', 'Nip') }}
{{ Form::text('nip',null,array('class'=>'form-control','placeholder'
=> 'Masukkan Nip','autofocus')) }}

<span class="text-danger">{{ $errors->first('nip') }}</span>

</div>

<div class="form-group">

{{ Form::label('nupt', 'Nupt') }}

{{ Form::text('nupt',null,array('class'=>'form-
control','placeholder' => 'Masukkan Nupt','autofocus')) }}

<span class="text-danger">{{ $errors->first('nupt') }}</span>

</div>

<div class="form-group">

{{ Form::label('JABATAN', 'JABATAN') }}

{{ Form::select('jabatan', array('Kepala Sekolah' => 'Kepala


Sekolah',

'Guru' => 'Guru',

'Staff TU' => 'Staff TU',

'Keamanan' => 'Keamanan'),


'Psc',array('class'=>'form-control')) }}

<span class="text-danger">{{ $errors->first('jabatan') }}</span>

</div>

<div class="form-group">

{{ Form::label('Status', 'Status') }}
{{ Form::select('status', array('PNS' => 'PNS',

'Honor' => 'Honor'),


'Psc',array('class'=>'form-control')) }}

<span class="text-danger">{{ $errors->first('status') }}</span>

</div>

<div class="form-group">

{{ Form::label('tgl_lahir', 'Tanggal Lahir') }}

{{ Form::date('tgl_lahir',null,array('class'=>'form-
control','placeholder' => 'Tanggal Lahir','autofocus','rows'=>'3',)) }}

<span class="text-danger">{{ $errors->first('tgl_lahir')


}}</span>

</div>

<button type="submit" class="btn btn-


primary">{{ $btn_submit }}</button>

{!! Form::close() !!}

</div>

</div>

</div>

</div>

</div>
@endsection

Controller Data Guru Admin

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class TendikController extends Controller

public function index()

$data['tendiks'] = \App\Tendik::paginate(100);

$data['judul'] = "GURU";

return view('tendik_index',$data);

public function tambah()

$data['tendik'] = new \App\Tendik();

$data['action'] = 'TendikController@simpan';
$data['btn_submit'] = 'SIMPAN';

$data['method'] = "POST";

return view('tendik_form',$data);

public function simpan(Request $request)

$validasi = $this->validate($request,[

'nama' => 'required',

'jenkel' => 'required',

'mapel' => 'required',

'nik' => 'required',

'nip' => '',

'nupt' => '',

'jabatan' => 'required',

'status' => 'required',

'tgl_lahir' => 'date',

]);

$requestData = $request->all();

\App\Tendik::create($requestData);

return back()->with('pesan', 'Data sudah disimpan!');


}

public function hapus($id)

$tendik = \App\Tendik::findOrFail($id);

$tendik->delete();

return back()->with('pesan','Data sudah dihapus!');

public function edit($id)

$data['tendik'] = \App\Tendik::findOrFail($id);

$data['method'] = "PUT";

$data['btn_submit'] = "UPDATE";

$data['action'] = array('TendikController@update', $id);

return view('tendik_form',$data);

public function update(Request $request, $id)

$tendik = \App\Tendik::findOrFail($id);

$validasi = $this->validate($request,[

'nama' => 'required',


'jenkel' => 'required',

'mapel' => 'required',

'nik' => 'required',

'nip' => '',

'nupt' => '',

'jabatan' => 'required',

'status' => 'required',

'tgl_lahir' => 'date',

]);

$requestData = $request->all();

$tendik->update($requestData);

return redirect('admin/tendik')->with('pesan', 'Data diubah!');

Halaman Data Murid Admin

@extends('layouts.app')

@section('content')

<div class="container">

<div class="row justify-content-center">

<div class="col-md-16">

<div class="card">
<div class="card-header">DATA {{ $judul }}</div>

<div class="card-body">

<table width="1170" border="2">

<thead>

<tr>

<th><center>NO</center></th>

<th><center>NAMA</center></th>

<th><center>JENIS KELAMIN</center></th>

<th><center>NIK</center></th>

<th><center>NISN</center></th>

<th><center>TINGKAT</center></th>

<th><center>JURUSAN</center></th>

<th><center>TANGGAL LAHIR</center></th>

<th><center>ORANG TUA</center></th>

</tr>

</thead>

<tbody>

@foreach ($murids as $murid)


<tr>

<td><center>{{ $loop->iteration }}</center></td>

<td><center>{{ $murid->nama }}</center></td>

<td><center>{{ $murid->jenkel }}</center></td>

<td><center>{{ $murid->nik }}</center></td>

<td><center>{{ $murid->nisn }}</center></td>

<td><center>{{ $murid->tingkat }}</center></td>

<td><center>{{ $murid->jurusan }}</center></td>

<td><center>{{ $murid->tgl_lhr }}</center></td>

<td><center>{{ $murid->ortu }}</center></td>

<td><center>

<a href="{{ url('admin/murid/edit/'.$murid->id) }}" class="btn btn-


info" > Ubah</a>

&nbsp;

<a href="{{ url('admin/murid/hapus/'.$murid->id) }}" class="btn btn-


danger" onclick="return confirm('Anda yakin?')" > Hapus </a>

</td></center>

</tr>

@endforeach
</tbody>

</table>

{{ $murids->links() }}

</div>

</div>

</div>

</div>

</div>

@endsection

Halaman Tambah Data Murid

@extends('layouts.app')

@section('content')

<div class="container">

<div class="row justify-content-center">

<div class="col-md-8">

<div class="card">

<div class="card-header">MURID</div>

<div class="card-body">
{{{ Form::model($murid, array('action' => $action, 'files' => true,
'method' => $method)) }}}

<div class="form-group">

{{ Form::label('nama', 'NAMA') }}

{{ Form::text('nama',null,array('class'=>'form-
control','placeholder' => 'Masukkan Nama','autofocus')) }}

<span class="text-danger">{{ $errors->first('nama') }}</span>

</div>

<div class="form-group">

{{ Form::label('Jenis Kelamin', 'Jenis Kelamin') }}

<br>

{{ Form::radio('jenkel', 'L', true)}} Laki-Laki

{{ Form::radio('jenkel', 'P', false)}} Perempuan

<span class="text-danger">{{ $errors->first('jenkel') }}</span>

</div>

<div class="form-group">

{{ Form::label('nik', 'Nik') }}
{{ Form::text('nik',null,array('class'=>'form-control','placeholder'
=> 'Masukkan Nik','autofocus')) }}

<span class="text-danger">{{ $errors->first('nik') }}</span>

</div>

<div class="form-group">

{{ Form::label('nisn', 'Nisn') }}

{{ Form::text('nisn',null,array('class'=>'form-
control','placeholder' => 'Masukkan Nisn','autofocus')) }}

<span class="text-danger">{{ $errors->first('nisn') }}</span>

</div>

<div class="form-group">

{{ Form::label('TINGKAT', 'TINGKAT') }}

{{ Form::select('tingkat', array('X' => 'X',

'XI' => 'XI',

'XII' => 'XII'), 'Psc',array('class'=>'form-


control')) }}

<span class="text-danger">{{ $errors->first('tingkat') }}</span>

</div>

<div class="form-group">

{{ Form::label('JURUSAN', 'JURUSAN') }}

{{ Form::select('jurusan', array('MIA' => 'MIA',


'IIS' => 'IIS',), 'Psc',array('class'=>'form-
control')) }}

<span class="text-danger">{{ $errors->first('jurusan') }}</span>

</div>

<div class="form-group">

{{ Form::label('tgl_lhr', 'Tanggal Lahir') }}

{{ Form::date('tgl_lhr',null,array('class'=>'form-
control','placeholder' => 'Tanggal Lahir','autofocus','rows'=>'3',)) }}

<span class="text-danger">{{ $errors->first('tgl_lhr') }}</span>

</div>

<div class="form-group">

{{ Form::label('ortu', 'Nama Orang Tua') }}

{{ Form::text('ortu',null,array('class'=>'form-
control','placeholder' => 'Masukkan Nama Orang Tua','autofocus')) }}

<span class="text-danger">{{ $errors->first('ortu') }}</span>

</div>

<button type="submit" class="btn btn-


primary">{{ $btn_submit }}</button>

{!! Form::close() !!}

</div>
</div>

</div>

</div>

</div>

@endsection

Controller Data Murid Admin

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class MuridController extends Controller

public function index()

$data['murids'] = \App\Murid::paginate(100);

$data['judul'] = "Murid";

return view('murid_index',$data);

public function tambah()


{

$data['murid'] = new \App\Murid();

$data['action'] = 'MuridController@simpan';

$data['btn_submit'] = 'SIMPAN';

$data['method'] = "POST";

return view('murid_form',$data);

public function simpan(Request $request)

$validasi = $this->validate($request,[

'nama' => 'required',

'jenkel' => 'required',

'nik' => '',

'nisn' => 'required',

'tingkat' => 'required',

'jurusan' => 'required',

'tgl_lhr' => 'date',

'ortu' => 'required',

]);

$requestData = $request->all();
\App\Murid::create($requestData);

return back()->with('pesan', 'Data sudah disimpan!');

public function hapus($id)

$murid = \App\Murid::findOrFail($id);

$murid->delete();

return back()->with('pesan','Data sudah dihapus!');

public function edit($id)

$data['murid'] = \App\Murid::findOrFail($id);

$data['method'] = "PUT";

$data['btn_submit'] = "UPDATE";

$data['action'] = array('MuridController@update', $id);

return view('murid_form',$data);

public function update(Request $request, $id)

$murid = \App\Murid::findOrFail($id);

$validasi = $this->validate($request,[
'nama' => 'required',

'jenkel' => 'required',

'nik' => '',

'nisn' => 'required',

'tingkat' => 'required',

'jurusan' => 'required',

'tgl_lhr' => 'date',

'ortu' => 'required',

]);

$requestData = $request->all();

$murid->update($requestData);

return redirect('admin/murid')->with('pesan', 'Data diubah!');

Halaman Data Materi Admin

@extends('layouts.app')

@section('content')

<div class="container">

<div class="row justify-content-center">

<div class="col-md-16">

<div class="card">
<div class="card-header">DATA {{ $judul }}</div>

<div class="card-body">

<table width="1170" border="2">

<thead>

<tr>

<th><center>NO</center></th>

<th><center>NAMA</center></th>

</tr>

</thead>

<tbody>

@foreach ($materis as $materi)

<tr>

<td><center>{{ $loop->iteration }}</center></td>

<td><center>{{ $materi->name }}</center></td>

<td><center>

<a href="{{ url('admin/materi/edit/'.$materi->id) }}" class="btn btn-


info" > Ubah</a>
&nbsp;

<a href="{{ url('admin/materi/hapus/'.$materi->id) }}" class="btn


btn-danger" onclick="return confirm('Anda yakin?')" > Hapus </a>

</td></center>

</tr>

@endforeach

</tbody>

</table>

{{ $materis->links() }}

</div>

</div>

</div>

</div>

</div>

@endsection

Halaman Tambah Data Materi

@extends('layouts.app')
@section('content')

<div class="container">

<div class="row justify-content-center">

<div class="col-md-8">

<div class="card">

<div class="card-header">MATERI</div>

<div class="card-body">

{{{ Form::model($materi, array('action' => $action, 'files' => true,


'method' => $method)) }}}

<div class="form-group">

{{ Form::label('name', 'NAMA Pelajaran') }}

{{ Form::text('name',null,array('class'=>'form-
control','placeholder' => 'Masukkan Nama','autofocus')) }}

<span class="text-danger">{{ $errors->first('name') }}</span>

</div>

<div class="form-group">

{{ Form::label('path', 'Pilih File') }}

{!! Form::file('path', ['class' => 'form-control']) !!}

<span class="text-danger">{{ $errors->first('path') }}</span>

</div>
<button type="submit" class="btn btn-
primary">{{ $btn_submit }}</button>

{!! Form::close() !!}

</div>

</div>

</div>

</div>

</div>

@endsection

Controller Data Materi

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use DB;

class MateriController extends Controller

public function index()


{

$data['materis'] = \App\Materi::paginate(100);

$data['judul'] = "Materi";

return view('materi_index',$data);

public function tambah()

$data['materi'] = new \App\Materi();

$data['action'] = 'MateriController@simpan';

$data['btn_submit'] = 'SIMPAN';

$data['method'] = "POST";

return view('materi_form',$data);

public function simpan(Request $request)

$validasi = $this->validate($request,[

'name' => 'required',

'path' => 'required|file',

]);

$file_nama = $request->file('path')->store('public/file');
$requestData = $request->all();

$requestData['path'] = $file_nama;

\App\Materi::create($requestData);

return back()->with('pesan', 'Data sudah disimpan!');

public function hapus($id)

$materi = \App\Materi::findOrFail($id);

$path = $materi->path;

@\Storage::delete($path);

$materi->delete();

return back()->with('pesan','Data sudah dihapus!');

public function edit($id)

$data['materi'] = \App\Materi::findOrFail($id);

$data['method'] = "PUT";

$data['btn_submit'] = "UPDATE";
$data['action'] = array('MateriController@update', $id);

return view('materi_form',$data);

public function update(Request $request, $id)

$materi = \App\Materi::findOrFail($id);

$validasi = $this->validate($request,[

'name' => 'required',

'path' => 'required|file',

]);

$datafile = $materi->file;

@\Storage::delete($datafile);

$file_nama = $request->file('path')->store('public/file');

$requestData = $request->all();

$requestData['path'] = $file_nama;

$materi->update($requestData);

return redirect('admin/materi')->with('pesan', 'Data diubah!');

You might also like