Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Book Library #54

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/Helpers/Qs.php
Expand Up @@ -78,6 +78,11 @@ public static function getTeamAdministrative()
return ['admin', 'super_admin', 'accountant'];
}

public static function getTeamLibrarian()
{
return ['admin', 'super_admin', 'librarian'];
}

public static function hash($id)
{
$date = date('dMY').'CJ';
Expand Down Expand Up @@ -198,6 +203,11 @@ public static function userIsPTA()
return in_array(Auth::user()->user_type, self::getPTA());
}

public static function userIsLibrarian()
{
return in_array(Auth::user()->user_type, self::getTeamLibrarian());
}

public static function userIsMyChild($student_id, $parent_id)
{
$data = ['user_id' => $student_id, 'my_parent_id' =>$parent_id];
Expand Down
10 changes: 8 additions & 2 deletions app/Http/Controllers/SupportTeam/BookController.php
@@ -1,20 +1,26 @@
<?php

namespace App\Http\Controllers;
namespace App\Http\Controllers\SupportTeam;

use App\Book;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class BookController extends Controller
{

public function __construct()
{

}

/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}

/**
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Kernel.php
Expand Up @@ -2,6 +2,7 @@

namespace App\Http;

use App\Http\Middleware\Custom\Librarian;
use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel
Expand Down Expand Up @@ -69,5 +70,6 @@ class Kernel extends HttpKernel
'teamAccount' => \App\Http\Middleware\Custom\TeamAccount::class,
'examIsLocked' => \App\Http\Middleware\Custom\ExamIsLocked::class,
'my_parent' => \App\Http\Middleware\Custom\MyParent::class,
'librarian'=> Librarian::class,
];
}
23 changes: 23 additions & 0 deletions app/Http/Middleware/Custom/Librarian.php
@@ -0,0 +1,23 @@
<?php

namespace App\Http\Middleware\Custom;

use Closure;
use Illuminate\Support\Facades\Auth;
use App\Helpers\Qs;

class Librarian
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
return (Auth::check() && Qs::userIsLibrarian()) ? $next($request) : redirect()->route('login');
}

}
12 changes: 11 additions & 1 deletion app/Models/Book.php
Expand Up @@ -6,5 +6,15 @@

class Book extends Model
{
//
protected $fillable = [
'name',
'my_class_id',
'description',
'author',
'book_type',
'url',
'location',
'total_copies',
'issued_copies'
];
}
2 changes: 1 addition & 1 deletion database/seeders/UserTypesTableSeeder.php
Expand Up @@ -19,7 +19,7 @@ public function run()
['title' => 'teacher', 'name' => 'Teacher', 'level' => 3],
['title' => 'admin', 'name' => 'Admin', 'level' => 2],
['title' => 'super_admin', 'name' => 'Super Admin', 'level' => 1],
// ['title' => 'librarian', 'name' => 'librarian', 'level' => 6],
['title' => 'librarian', 'name' => 'librarian', 'level' => 6],
];
DB::table('user_types')->insert($data);
}
Expand Down
9 changes: 9 additions & 0 deletions database/seeders/UsersTableSeeder.php
Expand Up @@ -73,6 +73,15 @@ protected function createNewUsers()
'code' => strtoupper(Str::random(10)),
'remember_token' => Str::random(10),
],

['name' => 'Librarian Youness',
'email' => 'lib@lib.com',
'user_type' => 'librarian',
'username' => 'librarian',
'password' => $password,
'code' => strtoupper(Str::random(10)),
'remember_token' => Str::random(10),
],
];
DB::table('users')->insert($d);
}
Expand Down
1 change: 1 addition & 0 deletions readme.md
Expand Up @@ -55,6 +55,7 @@ After seeding. Login details as follows:
| Parent | parent | parent@parent.com | cj |
| Accountant | accountant | accountant@accountant.com | cj |
| Student | student | student@student.com | cj |
| Librarian | librarian | lib@lib.com | cj |

#### **FUNCTIONS OF ACCOUNTS**

Expand Down
4 changes: 2 additions & 2 deletions resources/views/pages/librarian/menu.blade.php
@@ -1,4 +1,4 @@
{{--Books--}}
<li class="nav-item">
<a href="#" class="nav-link "><i class="icon-books"></i> Books</a>
</li>
<a href="{{route('book.index')}}" class="nav-link {{ in_array(Route::currentRouteName(), ['book.index']) ? 'active' : '' }}"><i class="icon-books"></i> Books</a>
</li>
5 changes: 5 additions & 0 deletions routes/web.php
Expand Up @@ -145,6 +145,11 @@
Route::resource('dorms', 'DormController');
Route::resource('payments', 'PaymentController');

/*************** Librarian *****************/
Route::group(['prefix' => 'librarian', 'middleware' => 'librarian'], function(){
Route::resource('book', 'BookController');
});

});

/************************ AJAX ****************************/
Expand Down