initial commit
This commit is contained in:
commit
28301e4312
219 changed files with 23035 additions and 0 deletions
51
app/Book.php
Executable file
51
app/Book.php
Executable file
|
@ -0,0 +1,51 @@
|
|||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Book extends Model {
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'author',
|
||||
'year',
|
||||
'stock',
|
||||
'category_id',
|
||||
'shelf_id'
|
||||
];
|
||||
|
||||
public function category()
|
||||
{
|
||||
|
||||
return $this->belongsTo('App\Category');
|
||||
|
||||
}
|
||||
|
||||
public function shelf()
|
||||
{
|
||||
|
||||
return $this->belongsTo('App\Shelf');
|
||||
|
||||
}
|
||||
|
||||
public function transactions()
|
||||
{
|
||||
|
||||
return $this->hasMany('App\Transaction');
|
||||
|
||||
}
|
||||
|
||||
public function scopeAvailable($query)
|
||||
{
|
||||
|
||||
return $query->where('stock', '>', 0);
|
||||
|
||||
}
|
||||
|
||||
public function scopeOrderByTitle($query)
|
||||
{
|
||||
|
||||
return $query->orderBy('title');
|
||||
|
||||
}
|
||||
|
||||
}
|
17
app/Category.php
Executable file
17
app/Category.php
Executable file
|
@ -0,0 +1,17 @@
|
|||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Category extends Model {
|
||||
|
||||
protected $fillable = [
|
||||
'category'
|
||||
];
|
||||
|
||||
|
||||
public function books()
|
||||
{
|
||||
return $this->hasMany('App\Book');
|
||||
}
|
||||
|
||||
}
|
7
app/Commands/Command.php
Executable file
7
app/Commands/Command.php
Executable file
|
@ -0,0 +1,7 @@
|
|||
<?php namespace App\Commands;
|
||||
|
||||
abstract class Command {
|
||||
|
||||
//
|
||||
|
||||
}
|
32
app/Console/Commands/Inspire.php
Executable file
32
app/Console/Commands/Inspire.php
Executable file
|
@ -0,0 +1,32 @@
|
|||
<?php namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
|
||||
class Inspire extends Command {
|
||||
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'inspire';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Display an inspiring quote';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
|
||||
}
|
||||
|
||||
}
|
29
app/Console/Kernel.php
Executable file
29
app/Console/Kernel.php
Executable file
|
@ -0,0 +1,29 @@
|
|||
<?php namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel {
|
||||
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
'App\Console\Commands\Inspire',
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
$schedule->command('inspire')
|
||||
->hourly();
|
||||
}
|
||||
|
||||
}
|
7
app/Events/Event.php
Executable file
7
app/Events/Event.php
Executable file
|
@ -0,0 +1,7 @@
|
|||
<?php namespace App\Events;
|
||||
|
||||
abstract class Event {
|
||||
|
||||
//
|
||||
|
||||
}
|
42
app/Exceptions/Handler.php
Executable file
42
app/Exceptions/Handler.php
Executable file
|
@ -0,0 +1,42 @@
|
|||
<?php namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler {
|
||||
|
||||
/**
|
||||
* A list of the exception types that should not be reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
'Symfony\Component\HttpKernel\Exception\HttpException'
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||
*
|
||||
* @param \Exception $e
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $e)
|
||||
{
|
||||
return parent::report($e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $e
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $e)
|
||||
{
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
|
||||
}
|
12
app/Fine.php
Executable file
12
app/Fine.php
Executable file
|
@ -0,0 +1,12 @@
|
|||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Fine extends Model {
|
||||
|
||||
protected $fillable = [
|
||||
'days',
|
||||
'fines'
|
||||
];
|
||||
|
||||
}
|
0
app/Handlers/Commands/.gitkeep
Executable file
0
app/Handlers/Commands/.gitkeep
Executable file
0
app/Handlers/Events/.gitkeep
Executable file
0
app/Handlers/Events/.gitkeep
Executable file
41
app/Http/Controllers/Auth/AuthController.php
Executable file
41
app/Http/Controllers/Auth/AuthController.php
Executable file
|
@ -0,0 +1,41 @@
|
|||
<?php namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Contracts\Auth\Registrar;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
|
||||
|
||||
class AuthController extends Controller {
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Registration & Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users, as well as the
|
||||
| authentication of existing users. By default, this controller uses
|
||||
| a simple trait to add these behaviors. Why don't you explore it?
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesAndRegistersUsers;
|
||||
|
||||
//kalo sudah login redirect kemana
|
||||
protected $redirectTo = '/';
|
||||
|
||||
/**
|
||||
* Create a new authentication controller instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Guard $auth
|
||||
* @param \Illuminate\Contracts\Auth\Registrar $registrar
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth, Registrar $registrar)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->registrar = $registrar;
|
||||
|
||||
$this->middleware('guest', ['except' => 'getLogout']);
|
||||
}
|
||||
|
||||
}
|
38
app/Http/Controllers/Auth/PasswordController.php
Executable file
38
app/Http/Controllers/Auth/PasswordController.php
Executable file
|
@ -0,0 +1,38 @@
|
|||
<?php namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Contracts\Auth\PasswordBroker;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class PasswordController extends Controller {
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Create a new password controller instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Guard $auth
|
||||
* @param \Illuminate\Contracts\Auth\PasswordBroker $passwords
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth, PasswordBroker $passwords)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->passwords = $passwords;
|
||||
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
}
|
96
app/Http/Controllers/BookController.php
Executable file
96
app/Http/Controllers/BookController.php
Executable file
|
@ -0,0 +1,96 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Book;
|
||||
use App\Category;
|
||||
use App\Shelf;
|
||||
use App\Http\Requests\BookRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BookController extends Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->middleware('auth');
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$books = Book::with('category', 'shelf')->get();
|
||||
|
||||
return view('lms.settings.book.book', compact('books'));
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
$categories = Category::lists('category', 'id');
|
||||
$shelves = Shelf::lists('shelf', 'id');
|
||||
|
||||
$tanggal = date('Y-m-d');
|
||||
$ambilTahun = substr($tanggal, 0, 4);
|
||||
for($tahun = 1990; $tahun <= $ambilTahun; $tahun++){
|
||||
$years[] = $tahun;
|
||||
}
|
||||
|
||||
return view('lms.settings.book.add', compact('categories', 'shelves', 'years'));
|
||||
}
|
||||
|
||||
public function store(BookRequest $request)
|
||||
{
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$book = Book::create($input);
|
||||
|
||||
session()->flash('flash_message', 'You have been addded 1 book!');
|
||||
|
||||
return redirect()->route('settings.book');
|
||||
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
|
||||
$book = Book::findOrFail($id);
|
||||
$categories = Category::lists('category', 'id');
|
||||
$shelves = Shelf::lists('shelf', 'id');
|
||||
|
||||
return view('lms.settings.book.edit', compact('book', 'categories', 'shelves'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function update($id, BookRequest $request)
|
||||
{
|
||||
|
||||
$book = Book::findOrFail($id);
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$book->update($input);
|
||||
|
||||
session()->flash('flash_message', 'You have been updated 1 book!');
|
||||
|
||||
return redirect()->route('settings.book');
|
||||
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
|
||||
$book = Book::findOrFail($id);
|
||||
|
||||
$book->delete();
|
||||
|
||||
session()->flash('flash_message', 'You have been deleted 1 book!');
|
||||
|
||||
return redirect()->route('settings.book');
|
||||
|
||||
}
|
||||
|
||||
}
|
85
app/Http/Controllers/CategoryController.php
Executable file
85
app/Http/Controllers/CategoryController.php
Executable file
|
@ -0,0 +1,85 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Category;
|
||||
use App\Http\Requests\CategoryRequest;
|
||||
|
||||
class CategoryController extends Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->middleware('auth');
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$categories = Category::get();
|
||||
|
||||
return view('lms.settings.category.category', compact('categories'));
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
return view('lms.settings.category.add');
|
||||
|
||||
}
|
||||
|
||||
public function store(CategoryRequest $request)
|
||||
{
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$category = Category::create($input);
|
||||
|
||||
session()->flash('flash_message', 'You have been addded 1 category!');
|
||||
|
||||
return redirect()->route('settings.category');
|
||||
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
|
||||
$category = Category::findOrFail($id);
|
||||
|
||||
return view('lms.settings.category.edit', compact('category'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function update($id, CategoryRequest $request)
|
||||
{
|
||||
|
||||
$category = Category::findOrFail($id);
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
session()->flash('flash_message', 'You have been updated 1 category!');
|
||||
|
||||
$category->update($input);
|
||||
|
||||
return redirect()->route('settings.category');
|
||||
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
|
||||
$category = Category::findOrFail($id);
|
||||
|
||||
$category->delete();
|
||||
|
||||
session()->flash('flash_message', 'You have been deleted 1 category!');
|
||||
|
||||
return redirect()->route('settings.category');
|
||||
|
||||
}
|
||||
|
||||
}
|
11
app/Http/Controllers/Controller.php
Executable file
11
app/Http/Controllers/Controller.php
Executable file
|
@ -0,0 +1,11 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesCommands;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
|
||||
abstract class Controller extends BaseController {
|
||||
|
||||
use DispatchesCommands, ValidatesRequests;
|
||||
|
||||
}
|
50
app/Http/Controllers/FinesController.php
Executable file
50
app/Http/Controllers/FinesController.php
Executable file
|
@ -0,0 +1,50 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Fine;
|
||||
use App\Http\Requests\FinesRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FinesController extends Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->middleware('auth');
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$fines = Fine::get();
|
||||
|
||||
return view('lms.settings.fine.fine', compact('fines'));
|
||||
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
|
||||
$fine = Fine::findOrFail($id);
|
||||
|
||||
return view('lms.settings.fine.edit', compact('fine'));
|
||||
|
||||
}
|
||||
|
||||
public function update($id, FinesRequest $request)
|
||||
{
|
||||
$fines = Fine::findOrFail($id);
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$fines->update($input);
|
||||
|
||||
session()->flash('flash_message', 'You have been updated fines!');
|
||||
|
||||
return redirect()->route('settings.fines');
|
||||
|
||||
}
|
||||
|
||||
}
|
57
app/Http/Controllers/PagesController.php
Executable file
57
app/Http/Controllers/PagesController.php
Executable file
|
@ -0,0 +1,57 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Book;
|
||||
use App\Category;
|
||||
use App\Shelf;
|
||||
use App\Periode;
|
||||
use App\Student;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PagesController extends Controller {
|
||||
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->middleware('auth');
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$tglSekarang = time();
|
||||
|
||||
$students = Student::get();
|
||||
|
||||
foreach ($students as $student) {
|
||||
|
||||
$dateDiff = $tglSekarang - $student['registered_at'];
|
||||
$durasi = floor($dateDiff/(60 * 60 * 24));
|
||||
$periode = Periode::first();
|
||||
if($durasi > $periode['days']){
|
||||
$student->update(['status' => 0]);
|
||||
}
|
||||
else{
|
||||
$student->update(['status' => 1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return view('lms.index');
|
||||
|
||||
}
|
||||
|
||||
public function books()
|
||||
{
|
||||
|
||||
$books = Book::with('category', 'shelf')->orderByTitle()->get();
|
||||
|
||||
return view('lms.books', compact('books'));
|
||||
|
||||
}
|
||||
|
||||
}
|
148
app/Http/Controllers/PeminjamanController.php
Executable file
148
app/Http/Controllers/PeminjamanController.php
Executable file
|
@ -0,0 +1,148 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Book;
|
||||
use App\Student;
|
||||
use App\Transaction;
|
||||
use App\Fine;
|
||||
use App\Category;
|
||||
use App\Http\Requests\PeminjamanRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PeminjamanController extends Controller {
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->middleware('auth');
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
//$books = Book::available()->orderByTitle()->lists('title', 'id');
|
||||
$students = Student::notLimit()->active()->orderByName()->lists('name', 'id');
|
||||
//$categories = Category::lists('category', 'id');
|
||||
$categories = Category::get();
|
||||
|
||||
|
||||
return view('lms.peminjaman.peminjaman', compact('students', 'categories'));
|
||||
|
||||
}
|
||||
|
||||
public function store(PeminjamanRequest $request)
|
||||
{
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$book_id = $input['book_id'];
|
||||
|
||||
$student_id = $input['student_id'];
|
||||
|
||||
$input['borrowed_at'] = time();
|
||||
|
||||
$transaction = Transaction::create($input);
|
||||
|
||||
$book = Book::findOrFail($book_id);
|
||||
|
||||
$stock = $book['stock'] - 1;
|
||||
|
||||
$book->update(['stock' => $stock]);
|
||||
|
||||
$student = Student::findOrFail($student_id);
|
||||
|
||||
$borrow = $student['borrow'] + 1;
|
||||
|
||||
$student->update(['borrow' => $borrow]);
|
||||
|
||||
session()->flash('flash_message', 'You have been added 1 transaction!');
|
||||
|
||||
return redirect()->route('peminjaman.laporan');
|
||||
|
||||
}
|
||||
|
||||
public function laporan()
|
||||
{
|
||||
$tglSekarang = time();
|
||||
|
||||
$transactions = Transaction::with('student', 'book')->notReturnedYet()->get();
|
||||
|
||||
foreach ($transactions as $transaction) {
|
||||
|
||||
$dateDiff = $tglSekarang - $transaction['borrowed_at'];
|
||||
$durasi = floor($dateDiff/(60 * 60 * 24));
|
||||
$fines = Fine::first();
|
||||
if($durasi > $fines['days']){
|
||||
$hariDenda = $durasi - $fines['days'];
|
||||
$denda = $hariDenda * $fines['fines'];
|
||||
$transaction->update(['fines' => $denda]);
|
||||
}
|
||||
else{
|
||||
$denda = 0;
|
||||
$transaction->update(['fines' => $denda]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//ambil tanggal
|
||||
//$date2 = mktime(0,0,0,05,31,2015);
|
||||
//return $date2;
|
||||
return view('lms.peminjaman.laporan', compact('transactions', 'durasi'));
|
||||
}
|
||||
|
||||
public function pengembalian($id)
|
||||
{
|
||||
$returnedAt = time();
|
||||
|
||||
$transaction = Transaction::findOrFail($id);
|
||||
|
||||
$transaction->update(['status' => 1, 'returned_at' => $returnedAt]);
|
||||
|
||||
//ini bisa langsung, cuman kan harus ambil data stock nya dulu mzzz
|
||||
//$transaction->book()->update(['stock' => 7]);
|
||||
|
||||
$book = Book::findOrFail($transaction['book_id']);
|
||||
|
||||
$stock = $book['stock'] + 1;
|
||||
|
||||
$book->update(['stock' => $stock]);
|
||||
|
||||
$student = Student::findOrFail($transaction['student_id']);
|
||||
|
||||
$borrow = $student['borrow'] - 1;
|
||||
|
||||
$student->update(['borrow' => $borrow]);
|
||||
|
||||
session()->flash('flash_message', 'You have been doing 1 returned transaction!');
|
||||
|
||||
return redirect()->route('peminjaman.histori');
|
||||
|
||||
}
|
||||
|
||||
public function perpanjang($id)
|
||||
{
|
||||
|
||||
$transaction = Transaction::findOrFail($id);
|
||||
|
||||
$dateNow = time();
|
||||
|
||||
$transaction->update(['borrowed_at' => $dateNow, 'fines' => 0]);
|
||||
|
||||
session()->flash('flash_message', 'You have been added 1 perpanjang!');
|
||||
|
||||
return redirect()->route('peminjaman.laporan');
|
||||
|
||||
}
|
||||
|
||||
public function histori()
|
||||
{
|
||||
$transactions = Transaction::returned()->get();
|
||||
|
||||
return view('lms.peminjaman.histori', compact('transactions'));
|
||||
}
|
||||
|
||||
|
||||
}
|
71
app/Http/Controllers/PeriodeController.php
Executable file
71
app/Http/Controllers/PeriodeController.php
Executable file
|
@ -0,0 +1,71 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Periode;
|
||||
use App\Student;
|
||||
use App\Http\Requests\PeriodeRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PeriodeController extends Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->middleware('auth');
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$periodes = Periode::get();
|
||||
|
||||
return view('lms.settings.periode.periode', compact('periodes'));
|
||||
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
|
||||
$periode = Periode::findOrFail($id);
|
||||
|
||||
return view('lms.settings.periode.edit', compact('periode'));
|
||||
|
||||
}
|
||||
|
||||
public function update($id, PeriodeRequest $request)
|
||||
{
|
||||
$periode = Periode::findOrFail($id);
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$periode->update($input);
|
||||
|
||||
//process
|
||||
$tglSekarang = time();
|
||||
|
||||
$students = Student::get();
|
||||
|
||||
foreach ($students as $student) {
|
||||
|
||||
$dateDiff = $tglSekarang - $student['registered_at'];
|
||||
$durasi = floor($dateDiff/(60 * 60 * 24));
|
||||
$periodes = Periode::first();
|
||||
if($durasi > $periodes['days']){
|
||||
$student->update(['status' => 0]);
|
||||
}
|
||||
else{
|
||||
$student->update(['status' => 1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
session()->flash('flash_message', 'You have been updated periode!');
|
||||
|
||||
return redirect()->route('settings.periode');
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
83
app/Http/Controllers/ShelfController.php
Executable file
83
app/Http/Controllers/ShelfController.php
Executable file
|
@ -0,0 +1,83 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Shelf;
|
||||
use App\Http\Requests\ShelfRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ShelfController extends Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->middleware('auth');
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$shelves = Shelf::get();
|
||||
|
||||
return view('lms.settings.shelf.shelf', compact('shelves'));
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
return view('lms.settings.shelf.add');
|
||||
|
||||
}
|
||||
|
||||
public function store(ShelfRequest $request)
|
||||
{
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$shelf = Shelf::create($input);
|
||||
|
||||
//flash messaging
|
||||
session()->flash('flash_message', 'You have been added 1 shelf!');
|
||||
|
||||
return redirect()->route('settings.shelf');
|
||||
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
|
||||
$shelf = Shelf::findOrFail($id);
|
||||
|
||||
return view('lms.settings.shelf.edit', compact('shelf'));
|
||||
|
||||
}
|
||||
|
||||
public function update($id, ShelfRequest $request)
|
||||
{
|
||||
|
||||
$shelf = Shelf::findOrFail($id);
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$shelf->update($input);
|
||||
|
||||
session()->flash('flash_message', 'You have been updated 1 shelf!');
|
||||
|
||||
return redirect()->route('settings.shelf');
|
||||
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
|
||||
$shelf = Shelf::findOrFail($id);
|
||||
|
||||
$shelf->delete();
|
||||
|
||||
session()->flash('flash_message', 'You have been deleted 1 shelf!');
|
||||
|
||||
return redirect()->route('settings.shelf');
|
||||
|
||||
}
|
||||
|
||||
}
|
114
app/Http/Controllers/StudentController.php
Executable file
114
app/Http/Controllers/StudentController.php
Executable file
|
@ -0,0 +1,114 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Student;
|
||||
use App\Http\Requests\StudentRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class StudentController extends Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->middleware('auth');
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$students = Student::get();
|
||||
|
||||
return view('lms.settings.student.student', compact('students'));
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
return view('lms.settings.student.add');
|
||||
|
||||
}
|
||||
|
||||
public function store(StudentRequest $request)
|
||||
{
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$input['registered_at'] = time();
|
||||
|
||||
$student = Student::create($input);
|
||||
|
||||
return redirect()->route('settings.student');
|
||||
|
||||
session()->flash('flash_message', 'You have been added 1 student!');
|
||||
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
|
||||
$student = Student::findOrFail($id);
|
||||
|
||||
return view('lms.settings.student.edit', compact('student'));
|
||||
|
||||
}
|
||||
|
||||
public function update($id, StudentRequest $request)
|
||||
{
|
||||
|
||||
$student = Student::findOrFail($id);
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$student->update($input);
|
||||
|
||||
session()->flash('flash_message', 'You have been updated 1 student!');
|
||||
|
||||
return redirect()->route('settings.student');
|
||||
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
|
||||
$student = Student::findOrFail($id);
|
||||
|
||||
$student->delete();
|
||||
|
||||
session()->flash('flash_message', 'You have been deleted 1 student!');
|
||||
|
||||
return redirect()->route('settings.student');
|
||||
|
||||
}
|
||||
|
||||
public function down($id)
|
||||
{
|
||||
|
||||
$student = Student::findOrFail($id);
|
||||
|
||||
$student->update(['status' => 0, 'registered_at' => 12960000]);
|
||||
|
||||
session()->flash('flash_message', 'Anda telah mematikan masa aktif 1 siswa!');
|
||||
|
||||
return redirect()->route('settings.student');
|
||||
|
||||
}
|
||||
|
||||
public function up($id)
|
||||
{
|
||||
$dateNow = time();
|
||||
|
||||
$student = Student::findOrFail($id);
|
||||
|
||||
$student->update(['status' => 1, 'registered_at' => $dateNow]);
|
||||
|
||||
session()->flash('flash_message', 'Anda telah melakukan perpanjangan masa aktif siswa!');
|
||||
|
||||
return redirect()->route('settings.student');
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
32
app/Http/Kernel.php
Executable file
32
app/Http/Kernel.php
Executable file
|
@ -0,0 +1,32 @@
|
|||
<?php namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel {
|
||||
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
|
||||
'Illuminate\Cookie\Middleware\EncryptCookies',
|
||||
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
|
||||
'Illuminate\Session\Middleware\StartSession',
|
||||
'Illuminate\View\Middleware\ShareErrorsFromSession',
|
||||
'App\Http\Middleware\VerifyCsrfToken',
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => 'App\Http\Middleware\Authenticate',
|
||||
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
|
||||
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
|
||||
];
|
||||
|
||||
}
|
50
app/Http/Middleware/Authenticate.php
Executable file
50
app/Http/Middleware/Authenticate.php
Executable file
|
@ -0,0 +1,50 @@
|
|||
<?php namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
|
||||
class Authenticate {
|
||||
|
||||
/**
|
||||
* The Guard implementation.
|
||||
*
|
||||
* @var Guard
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new filter instance.
|
||||
*
|
||||
* @param Guard $auth
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->guest())
|
||||
{
|
||||
if ($request->ajax())
|
||||
{
|
||||
return response('Unauthorized.', 401);
|
||||
}
|
||||
else
|
||||
{
|
||||
return redirect()->guest('auth/login');
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
44
app/Http/Middleware/RedirectIfAuthenticated.php
Executable file
44
app/Http/Middleware/RedirectIfAuthenticated.php
Executable file
|
@ -0,0 +1,44 @@
|
|||
<?php namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class RedirectIfAuthenticated {
|
||||
|
||||
/**
|
||||
* The Guard implementation.
|
||||
*
|
||||
* @var Guard
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new filter instance.
|
||||
*
|
||||
* @param Guard $auth
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->check())
|
||||
{
|
||||
return new RedirectResponse(url('/home'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
20
app/Http/Middleware/VerifyCsrfToken.php
Executable file
20
app/Http/Middleware/VerifyCsrfToken.php
Executable file
|
@ -0,0 +1,20 @@
|
|||
<?php namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
|
||||
|
||||
class VerifyCsrfToken extends BaseVerifier {
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
return parent::handle($request, $next);
|
||||
}
|
||||
|
||||
}
|
32
app/Http/Requests/BookRequest.php
Executable file
32
app/Http/Requests/BookRequest.php
Executable file
|
@ -0,0 +1,32 @@
|
|||
<?php namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class BookRequest extends Request {
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'title' => 'required|min:5',
|
||||
'author' => 'required|min:4',
|
||||
'stock' => 'required|integer',
|
||||
'year' => 'required|integer|min:4'
|
||||
];
|
||||
}
|
||||
|
||||
}
|
31
app/Http/Requests/CategoryRequest.php
Executable file
31
app/Http/Requests/CategoryRequest.php
Executable file
|
@ -0,0 +1,31 @@
|
|||
<?php namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class CategoryRequest extends Request {
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
|
||||
'category' => 'required|min:3'
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
}
|
30
app/Http/Requests/FinesRequest.php
Executable file
30
app/Http/Requests/FinesRequest.php
Executable file
|
@ -0,0 +1,30 @@
|
|||
<?php namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class FinesRequest extends Request {
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'days' => 'required|integer',
|
||||
'fines' => 'required|integer'
|
||||
];
|
||||
}
|
||||
|
||||
}
|
29
app/Http/Requests/PeminjamanRequest.php
Executable file
29
app/Http/Requests/PeminjamanRequest.php
Executable file
|
@ -0,0 +1,29 @@
|
|||
<?php namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class PeminjamanRequest extends Request {
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
}
|
29
app/Http/Requests/PeriodeRequest.php
Executable file
29
app/Http/Requests/PeriodeRequest.php
Executable file
|
@ -0,0 +1,29 @@
|
|||
<?php namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class PeriodeRequest extends Request {
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'days' => 'required|integer'
|
||||
];
|
||||
}
|
||||
|
||||
}
|
9
app/Http/Requests/Request.php
Executable file
9
app/Http/Requests/Request.php
Executable file
|
@ -0,0 +1,9 @@
|
|||
<?php namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
abstract class Request extends FormRequest {
|
||||
|
||||
//
|
||||
|
||||
}
|
29
app/Http/Requests/ShelfRequest.php
Executable file
29
app/Http/Requests/ShelfRequest.php
Executable file
|
@ -0,0 +1,29 @@
|
|||
<?php namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class ShelfRequest extends Request {
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'shelf' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
}
|
31
app/Http/Requests/StudentRequest.php
Executable file
31
app/Http/Requests/StudentRequest.php
Executable file
|
@ -0,0 +1,31 @@
|
|||
<?php namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class StudentRequest extends Request {
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
|
||||
'name' => 'required|min:5'
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
}
|
192
app/Http/routes.php
Executable file
192
app/Http/routes.php
Executable file
|
@ -0,0 +1,192 @@
|
|||
<?php
|
||||
use App\Book;
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register all of the routes for an application.
|
||||
| It's a breeze. Simply tell Laravel the URIs it should respond to
|
||||
| and give it the controller to call when that URI is requested.
|
||||
|
|
||||
*/
|
||||
|
||||
//Route::get('/api/dropdown/peminjaman/{id}', [
|
||||
// 'as' => 'api.dropdown.peminjaman', 'uses' => 'PeminjamanController@dropdown'
|
||||
// ]);
|
||||
|
||||
Route::get('/api/dropdown/peminjaman/{id}', function($id){
|
||||
|
||||
if(Request::ajax()){
|
||||
|
||||
//$category_id = Input::get('category_id');
|
||||
|
||||
$books = Book::available()->orderByTitle()->where('category_id', '=', $id)->get();
|
||||
|
||||
return Response::json($books);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
Route::get('/', [
|
||||
'as' => 'index', 'uses' => 'PagesController@index'
|
||||
]);
|
||||
Route::get('books', [
|
||||
'as' => 'books', 'uses' => 'PagesController@books'
|
||||
]);
|
||||
|
||||
Route::get('peminjaman', [
|
||||
'as' => 'peminjaman.peminjaman', 'uses' => 'PeminjamanController@index'
|
||||
]);
|
||||
Route::post('peminjaman', [
|
||||
'as' => 'peminjaman.post', 'uses' => 'PeminjamanController@store'
|
||||
]);
|
||||
|
||||
Route::get('laporan', [
|
||||
'as' => 'peminjaman.laporan', 'uses' => 'PeminjamanController@laporan'
|
||||
]);
|
||||
Route::get('pengembalian/{id}', [
|
||||
'as' => 'peminjaman.pengembalian', 'uses' => 'PeminjamanController@pengembalian'
|
||||
]);
|
||||
Route::get('perpanjang/{id}', [
|
||||
'as' => 'peminjaman.perpanjang', 'uses' => 'PeminjamanController@perpanjang'
|
||||
]);
|
||||
|
||||
Route::get('histori', [
|
||||
'as' => 'peminjaman.histori', 'uses' => 'PeminjamanController@histori'
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//setting
|
||||
|
||||
|
||||
//=================================================setting category====================================================
|
||||
Route::get('/settings/category', [
|
||||
'as' => 'settings.category', 'uses' => 'CategoryController@index'
|
||||
]);
|
||||
Route::get('/settings/category/add', [
|
||||
'as' => 'settings.category.add', 'uses' => 'CategoryController@add'
|
||||
]);
|
||||
Route::post('settings/category/add', [
|
||||
'as' => 'settings.category.post', 'uses' => 'CategoryController@store'
|
||||
]);
|
||||
Route::get('settings/category/edit/{id}', [
|
||||
'as' => 'settings.category.edit', 'uses' => 'CategoryController@edit'
|
||||
]);
|
||||
Route::patch('settings/category/edit/{id}', [
|
||||
'as' => 'settings.category.update', 'uses' => 'CategoryController@update'
|
||||
]);
|
||||
Route::get('settings/category/delete/{id}', [
|
||||
'as' => 'settings.category.delete', 'uses' => 'CategoryController@delete'
|
||||
]);
|
||||
//==========================================================================================================================
|
||||
|
||||
|
||||
//=================================================setting shelf==========================================================
|
||||
Route::get('/settings/shelf', [
|
||||
'as' => 'settings.shelf', 'uses' => 'ShelfController@index'
|
||||
]);
|
||||
Route::get('/settings/shelf/add', [
|
||||
'as' => 'settings.shelf.add', 'uses' => 'ShelfController@add'
|
||||
]);
|
||||
Route::post('settings/shelf/add', [
|
||||
'as' => 'settings.shelf.post', 'uses' => 'ShelfController@store'
|
||||
]);
|
||||
Route::get('settings/shelf/edit/{id}', [
|
||||
'as' => 'settings.shelf.edit', 'uses' => 'ShelfController@edit'
|
||||
]);
|
||||
Route::patch('settings/shelf/edit/{id}', [
|
||||
'as' => 'settings.shelf.update', 'uses' => 'ShelfController@update'
|
||||
]);
|
||||
Route::get('settings/category/delete/{id}', [
|
||||
'as' => 'settings.shelf.delete', 'uses' => 'ShelfController@delete'
|
||||
]);
|
||||
//==========================================================================================================================
|
||||
|
||||
|
||||
//=================================================setting fines==========================================================
|
||||
Route::get('/settings/fines', [
|
||||
'as' => 'settings.fines', 'uses' => 'FinesController@index'
|
||||
]);
|
||||
Route::get('settings/fines/edit/{id}', [
|
||||
'as' => 'settings.fines.edit', 'uses' => 'FinesController@edit'
|
||||
]);
|
||||
Route::patch('settings/fines/edit/{id}', [
|
||||
'as' => 'settings.fines.update', 'uses' => 'FinesController@update'
|
||||
]);
|
||||
//==========================================================================================================================
|
||||
|
||||
|
||||
//=================================================setting periode==========================================================
|
||||
Route::get('/settings/periode', [
|
||||
'as' => 'settings.periode', 'uses' => 'PeriodeController@index'
|
||||
]);
|
||||
Route::get('settings/periode/edit/{id}', [
|
||||
'as' => 'settings.periode.edit', 'uses' => 'PeriodeController@edit'
|
||||
]);
|
||||
Route::patch('settings/periode/edit/{id}', [
|
||||
'as' => 'settings.periode.update', 'uses' => 'PeriodeController@update'
|
||||
]);
|
||||
//==========================================================================================================================
|
||||
|
||||
//=================================================setting student==========================================================
|
||||
Route::get('/settings/student', [
|
||||
'as' => 'settings.student', 'uses' => 'StudentController@index'
|
||||
]);
|
||||
Route::get('/settings/student/add', [
|
||||
'as' => 'settings.student.add', 'uses' => 'StudentController@add'
|
||||
]);
|
||||
Route::post('settings/student/add', [
|
||||
'as' => 'settings.student.post', 'uses' => 'StudentController@store'
|
||||
]);
|
||||
Route::get('settings/student/edit/{id}', [
|
||||
'as' => 'settings.student.edit', 'uses' => 'StudentController@edit'
|
||||
]);
|
||||
Route::patch('settings/student/edit/{id}', [
|
||||
'as' => 'settings.student.update', 'uses' => 'StudentController@update'
|
||||
]);
|
||||
Route::get('settings/student/delete/{id}', [
|
||||
'as' => 'settings.student.delete', 'uses' => 'StudentController@delete'
|
||||
]);
|
||||
Route::get('settings/student/down/{id}', [
|
||||
'as' => 'settings.student.down', 'uses' => 'StudentController@down'
|
||||
]);
|
||||
Route::get('settings/student/up/{id}', [
|
||||
'as' => 'settings.student.up', 'uses' => 'StudentController@up'
|
||||
]);
|
||||
//==========================================================================================================================
|
||||
|
||||
//=================================================setting book=============================================================
|
||||
Route::get('/settings/book', [
|
||||
'as' => 'settings.book', 'uses' => 'BookController@index'
|
||||
]);
|
||||
Route::get('/settings/book/add', [
|
||||
'as' => 'settings.book.add', 'uses' => 'BookController@add'
|
||||
]);
|
||||
Route::post('settings/book/add', [
|
||||
'as' => 'settings.book.post', 'uses' => 'BookController@store'
|
||||
]);
|
||||
Route::get('settings/book/edit/{id}', [
|
||||
'as' => 'settings.book.edit', 'uses' => 'BookController@edit'
|
||||
]);
|
||||
Route::patch('settings/book/edit/{id}', [
|
||||
'as' => 'settings.book.update', 'uses' => 'BookController@update'
|
||||
]);
|
||||
Route::get('settings/book/delete/{id}', [
|
||||
'as' => 'settings.book.delete', 'uses' => 'BookController@delete'
|
||||
]);
|
||||
|
||||
//========================================================================================================================
|
||||
|
||||
|
||||
Route::controllers([
|
||||
'auth' => 'Auth\AuthController',
|
||||
'password' => 'Auth\PasswordController',
|
||||
]);
|
11
app/Periode.php
Executable file
11
app/Periode.php
Executable file
|
@ -0,0 +1,11 @@
|
|||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Periode extends Model {
|
||||
|
||||
protected $fillable = [
|
||||
'days'
|
||||
];
|
||||
|
||||
}
|
34
app/Providers/AppServiceProvider.php
Executable file
34
app/Providers/AppServiceProvider.php
Executable file
|
@ -0,0 +1,34 @@
|
|||
<?php namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* This service provider is a great spot to register your various container
|
||||
* bindings with the application. As you can see, we are registering our
|
||||
* "Registrar" implementation here. You can add your own bindings too!
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->bind(
|
||||
'Illuminate\Contracts\Auth\Registrar',
|
||||
'App\Services\Registrar'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
34
app/Providers/BusServiceProvider.php
Executable file
34
app/Providers/BusServiceProvider.php
Executable file
|
@ -0,0 +1,34 @@
|
|||
<?php namespace App\Providers;
|
||||
|
||||
use Illuminate\Bus\Dispatcher;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BusServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @param \Illuminate\Bus\Dispatcher $dispatcher
|
||||
* @return void
|
||||
*/
|
||||
public function boot(Dispatcher $dispatcher)
|
||||
{
|
||||
$dispatcher->mapUsing(function($command)
|
||||
{
|
||||
return Dispatcher::simpleMapping(
|
||||
$command, 'App\Commands', 'App\Handlers\Commands'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
}
|
23
app/Providers/ConfigServiceProvider.php
Executable file
23
app/Providers/ConfigServiceProvider.php
Executable file
|
@ -0,0 +1,23 @@
|
|||
<?php namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ConfigServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* Overwrite any vendor / package configuration.
|
||||
*
|
||||
* This service provider is intended to provide a convenient location for you
|
||||
* to overwrite any "vendor" or package configuration that you may want to
|
||||
* modify before the application handles the incoming request / command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
config([
|
||||
//
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
32
app/Providers/EventServiceProvider.php
Executable file
32
app/Providers/EventServiceProvider.php
Executable file
|
@ -0,0 +1,32 @@
|
|||
<?php namespace App\Providers;
|
||||
|
||||
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* The event handler mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $listen = [
|
||||
'event.name' => [
|
||||
'EventListener',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any other events for your application.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Events\Dispatcher $events
|
||||
* @return void
|
||||
*/
|
||||
public function boot(DispatcherContract $events)
|
||||
{
|
||||
parent::boot($events);
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
}
|
44
app/Providers/RouteServiceProvider.php
Executable file
44
app/Providers/RouteServiceProvider.php
Executable file
|
@ -0,0 +1,44 @@
|
|||
<?php namespace App\Providers;
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* This namespace is applied to the controller routes in your routes file.
|
||||
*
|
||||
* In addition, it is set as the URL generator's root namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'App\Http\Controllers';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @param \Illuminate\Routing\Router $router
|
||||
* @return void
|
||||
*/
|
||||
public function boot(Router $router)
|
||||
{
|
||||
parent::boot($router);
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @param \Illuminate\Routing\Router $router
|
||||
* @return void
|
||||
*/
|
||||
public function map(Router $router)
|
||||
{
|
||||
$router->group(['namespace' => $this->namespace], function($router)
|
||||
{
|
||||
require app_path('Http/routes.php');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
14
app/Role.php
Executable file
14
app/Role.php
Executable file
|
@ -0,0 +1,14 @@
|
|||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Role extends Model {
|
||||
|
||||
public function users()
|
||||
{
|
||||
|
||||
return $this->belongsToMany('App\User');
|
||||
|
||||
}
|
||||
|
||||
}
|
39
app/Services/Registrar.php
Executable file
39
app/Services/Registrar.php
Executable file
|
@ -0,0 +1,39 @@
|
|||
<?php namespace App\Services;
|
||||
|
||||
use App\User;
|
||||
use Validator;
|
||||
use Illuminate\Contracts\Auth\Registrar as RegistrarContract;
|
||||
|
||||
class Registrar implements RegistrarContract {
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
public function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => 'required|max:255',
|
||||
'email' => 'required|email|max:255|unique:users',
|
||||
'password' => 'required|confirmed|min:6',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return User
|
||||
*/
|
||||
public function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => bcrypt($data['password']),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
16
app/Shelf.php
Executable file
16
app/Shelf.php
Executable file
|
@ -0,0 +1,16 @@
|
|||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Shelf extends Model {
|
||||
|
||||
protected $fillable = [
|
||||
'shelf'
|
||||
];
|
||||
|
||||
public function books()
|
||||
{
|
||||
return $this->hasMany('App\Book');
|
||||
}
|
||||
|
||||
}
|
42
app/Student.php
Executable file
42
app/Student.php
Executable file
|
@ -0,0 +1,42 @@
|
|||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Student extends Model {
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'registered_at',
|
||||
'borrow',
|
||||
'status'
|
||||
];
|
||||
|
||||
public function transactions()
|
||||
{
|
||||
|
||||
return $this->hasMany('App\Transaction');
|
||||
|
||||
}
|
||||
|
||||
public function scopeNotLimit($query)
|
||||
{
|
||||
|
||||
return $query->where('borrow', '<', 3);
|
||||
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
{
|
||||
|
||||
return $query->where('status', 1);
|
||||
|
||||
}
|
||||
|
||||
public function scopeOrderByName($query)
|
||||
{
|
||||
|
||||
return $query->orderBy('name');
|
||||
|
||||
}
|
||||
|
||||
}
|
44
app/Transaction.php
Executable file
44
app/Transaction.php
Executable file
|
@ -0,0 +1,44 @@
|
|||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Transaction extends Model {
|
||||
|
||||
protected $fillable = [
|
||||
'student_id',
|
||||
'book_id',
|
||||
'borrowed_at',
|
||||
'returned_at',
|
||||
'fines',
|
||||
'status'
|
||||
];
|
||||
|
||||
public function student()
|
||||
{
|
||||
|
||||
return $this->belongsTo('App\Student');
|
||||
|
||||
}
|
||||
|
||||
public function book()
|
||||
{
|
||||
|
||||
return $this->belongsTo('App\Book');
|
||||
|
||||
}
|
||||
|
||||
public function scopeNotReturnedYet($query)
|
||||
{
|
||||
|
||||
return $query->where('status', 0);
|
||||
|
||||
}
|
||||
|
||||
public function scopeReturned($query)
|
||||
{
|
||||
|
||||
return $query->where('status', 1);
|
||||
|
||||
}
|
||||
|
||||
}
|
70
app/User.php
Executable file
70
app/User.php
Executable file
|
@ -0,0 +1,70 @@
|
|||
<?php namespace App;
|
||||
|
||||
use Illuminate\Auth\Authenticatable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Auth\Passwords\CanResetPassword;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
||||
|
||||
class User extends Model implements AuthenticatableContract, CanResetPasswordContract {
|
||||
|
||||
use Authenticatable, CanResetPassword;
|
||||
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'users';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['name', 'email', 'password'];
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = ['password', 'remember_token'];
|
||||
|
||||
public function roles()
|
||||
{
|
||||
|
||||
return $this->belongsToMany('App\Role');
|
||||
|
||||
}
|
||||
|
||||
public function assignRole($role)
|
||||
{
|
||||
|
||||
return $this->roles()->attach($role);
|
||||
|
||||
}
|
||||
|
||||
public function revokeRole($role)
|
||||
{
|
||||
|
||||
return $this->roles()->detach($role);
|
||||
|
||||
}
|
||||
|
||||
public function hasRole($name)
|
||||
{
|
||||
|
||||
foreach ($this->roles as $role) {
|
||||
|
||||
if ($role->name === $name) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue