Skip to content

Commit

Permalink
Migrations, Windows setup instructions, README updates
Browse files Browse the repository at this point in the history
- Created migrations in place of the SQL dump.
- Removed certain manually created timestamp attributes in favour for
Laravel's updated_at/created_at.
- Added windows installation instructions
- Updated .gitignore to NOT ignore the app/storage folder, but added a
.gitignore to each of the storage folders so that everything in them is
ignored. The reason for this is because not having the app/storage
folders at all causes artisan errors.
  • Loading branch information
Oliver Pennington authored and prabhakar267 committed Feb 26, 2018
1 parent fffe37b commit 47369b7
Show file tree
Hide file tree
Showing 19 changed files with 878 additions and 371 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/bootstrap/compiled.php
/vendor
app/storage/

/public/storage
/storage/*.key
Expand Down
77 changes: 53 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,66 @@ The backend of the system is developed on **[Laravel 4.2 PHP MVC Framework](http
The front end is built on **[Edmin Responsive Bootstrap Admin Template](http://egrappler.com/responsive-bootstrap-admin-template-edmin/)** ([Demo](http://www.egrappler.com/edmin/index.html)) which is built on [Bootstrap v2.2.2](http://bootstrapdocs.com/v2.2.2/docs/) using [jQuery](https://blog.jquery.com/2013/02/04/jquery-1-9-1-released/) and [Underscore-Dot-JS](http://underscorejs.org/)

## Setup
### Unix / Linux / Mac Setup

```shell
# PHP 5.6 and mcrypt extension are required for this project
apt-get update
apt-get install php5.6 php5.6-mcrypt
```
*NOTE:* PHP 5.6 and mcrypt extension are required for this project:

```shell
git clone https://github.com/prabhakar267/library-management-system.git
cd library-management-system
```
* `apt-get update`

```shell
[sudo] chmod -R 755 app/storage
```
* `apt-get install php5.6 php5.6-mcrypt`

```shell
composer install
```
* `git clone https://github.com/prabhakar267/library-management-system`

+ Edit [mysql.config.php.sample](app/config/mysql.config.php.sample) according to your MySQL configurations and save it in the same directory as ```mysql.config.php```
+ Open your MySQL console / MySQL administration tool (like [phpMyAdmin](https://www.phpmyadmin.net/)) and import the [database dump](database/library.sql)
* `cd library-management-system`

```shell
php artisan migrate
```
* `[sudo] chmod -R 755 app/storage`

```shell
php artisan serve
```
* `composer install`

* Edit [mysql.config.php.sample](app/config/mysql.config.php.sample) according to your MySQL configurations and save it in the same directory as ```mysql.config.php```

* `php artisan migrate`

* `php artisan serve`

### Windows Setup

*Some notes on Windows setup:*

*Obtaining the `mcrypt` extension for PHP 7+ is not trivial and involves compiling your own PHP build.
If your PHP version does not support `mcrypt` (i.e. if you have PHP 7+), then the easiest way to run Laravel 4.2 applications is to [download a compatible version of XAMPP](https://www.apachefriends.org/xampp-files/5.6.33/xampp-win32-5.6.33-0-VC11-installer.exe) and make sure the app is run with it.*

With the above notes in mind, Windows setup is not too tricky:

* Open git shell;

* `cd C:/path/to/xampp/htdocs`;

* `git clone https://github.com/prabhakar267/library-management-system`;

* `cd library-management-system`;

* `composer update`;

* **NOTE:** If your PHP version is not compatible with `mcrypt` you will receive an error here. Do not worry, simply perform these additional two steps:
* `C:/path/to/xampp5.6.33/php/php.exe artisan clear-compiled`
* `C:/path/to/xampp5.6.33/php/php.exe artisan cache:clear`

* Create a table for the app via phpmyadmin (or however you prefer);

* Edit `app/config/mysql.config.php.sample` according to your MySQL configurations and save it in the same directory as `mysql.config.php`;

* `php artisan migrate`

**OR IF YOUR PHP IS NOT `mcrypt` COMPATIBLE:**

`C:/path/to/xampp5.6.33/php/php.exe artisan migrate`

* `php artisan serve`

**OR IF YOUR PHP IS NOT `mcrypt` COMPATIBLE:**

`C:/path/to/xampp5.6.33/php/php.exe artisan serve`

## Features
+ Librarians can be given their authorized login ID and password without which system can not be accessed.
Expand All @@ -56,4 +86,3 @@ php artisan serve

--------------------------
Feel free to contact me via [email](http://goo.gl/68kmd6)

30 changes: 14 additions & 16 deletions app/controllers/BooksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public function index()

$book_list = Books::select('book_id','title','author','description','category_id')
->orderBy('book_id');

$this->filterQuery($book_list);

$book_list = $book_list->get();

for($i=0; $i<count($book_list); $i++){

$id = $book_list[$i]['book_id'];
$conditions = array(
'book_id' => $id,
Expand All @@ -35,7 +35,7 @@ public function index()
$book_list[$i]['total_books'] = Issue::select()
->where('book_id','=',$id)
->count();

$book_list[$i]['avaliable'] = Issue::select()
->where($conditions)
->count();
Expand Down Expand Up @@ -81,9 +81,9 @@ public function store()
$db_flag = true;
} else {
$number_of_issues = $books['number'];

for($i=0; $i<$number_of_issues; $i++){

$issues = Issue::create(array(
'book_id' => $newId,
'added_by' => $user_id
Expand All @@ -99,7 +99,7 @@ public function store()
throw new Exception('Invalid update data provided');

});

return "Books Added successfully to Database";

}
Expand All @@ -112,20 +112,20 @@ public function store()
* @return Response
*/
public function show($string)
{
{
$book_list = Books::select('book_id','title','author','description','category_id')
->where('title', 'like', '%' . $string . '%')
->orWhere('author', 'like', '%' . $string . '%')
->orderBy('book_id');

$book_list = $book_list->get();

foreach($book_list as $book){
$conditions = array(
'book_id' => $book->book_id,
'available_status' => 1
);

$count = Issue::where($conditions)
->count();

Expand All @@ -143,27 +143,25 @@ public function show($string)
* @return Response
*/
public function edit($id)
{
{
$issue = Issue::find($id);
if($issue == NULL){
throw new Exception('Invalid Book ID');
}

$issue->added_at_timestamp = date('d-M-y h:i A', strtotime($issue->added_at_timestamp));

$book = Books::find($issue->book_id);

$issue->book_name = $book->title;
$issue->author = $book->author;

$issue->category = Categories::find($book->category_id)
->category;

$issue->available_status = (bool)$issue->available_status;
if($issue->available_status == 1){
return $issue;
}

$conditions = array(
'return_time' => 0,
'book_issue_id' => $id,
Expand Down Expand Up @@ -225,7 +223,7 @@ public function destroy($id)
}


public function renderAddBooks() {
public function renderAddBooks() {
$db_control = new HomeController();

return View::make('panel.addbook')
Expand Down
16 changes: 8 additions & 8 deletions app/controllers/StudentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function index()

$this->filterQuery($students);
$students = $students->get();

return $students;
}

Expand All @@ -32,14 +32,14 @@ public function create()
'approved' => 1,
'rejected' => 0
);

$students = Student::select('student_id', 'first_name', 'last_name', 'category', 'roll_num', 'branch', 'year', 'email_id', 'books_issued')
->where($conditions)
->orderBy('student_id');

$this->filterQuery($students);
$students = $students->get();

return $students;
}

Expand Down Expand Up @@ -98,7 +98,7 @@ public function show($id)

$student_issued_books = Logs::select('book_issue_id', 'issued_at')
->where('student_id', '=', $id)
->orderBy('time_stamp', 'desc')
->orderBy('created_at', 'desc')
->take($student->books_issued)
->get();

Expand Down Expand Up @@ -136,19 +136,19 @@ public function edit($id)
*/
public function update($id){
$flag = (bool)Input::get('flag');

$student = Student::findOrFail($id);

if($flag){
// if student is approved
$student->approved = 1;
} else {
// if student is rejected for some reason
$student->rejected = 1;
}

$student->save();

return "Student's approval/rejection status successfully changed.";
}

Expand Down
39 changes: 39 additions & 0 deletions app/database/migrations/2018_02_24_194028_create_books_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateBooksTable extends Migration {

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('books', function(Blueprint $table)
{
$table->increments('book_id');

$table->string('title', 1000);
$table->string('author', 1000);
$table->text('description');
$table->integer('category_id')->unsigned();
$table->integer('added_by')->unsigned();

$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('books');
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateBookCategoriesTable extends Migration {

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('book_categories', function(Blueprint $table)
{
$table->increments('id');

$table->string('category', 255);

$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('book_categories');
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateBookIssueTable extends Migration {

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('book_issue', function(Blueprint $table)
{
$table->increments('issue_id');

$table->integer('book_id');
$table->tinyInteger('available_status')->default(1);
$table->integer('added_by')->unsigned();

$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('book_issue');
}

}
Loading

0 comments on commit 47369b7

Please sign in to comment.