public function delete($id)
 {
     $book = new \App\Book();
     $book->find($id)->delete();
     //$book->delete();
     return redirect('books');
 }
Ejemplo n.º 2
0
 function getExample6()
 {
     $book = new \App\Book();
     $book_to_update = $book->find(1);
     $book_to_update->title = 'Green Eggs adn Ham';
     $book_to_update->save();
     return 'Example  6';
 }
Ejemplo n.º 3
0
 function getExample3()
 {
     $books = new \App\Book();
     $all_books = $books->all();
     foreach ($all_books as $book) {
         echo $book->title . '<br>';
     }
     return 'Example 3';
 }
Ejemplo n.º 4
0
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $books = array(array('id' => 1, 'title' => 'The Fault in Our Stars', 'author' => 'John Green', 'publisher' => 'Qanita', 'category' => 'Novel', 'date' => '2012', 'stock' => 9, 'cover' => 'the_fault_in_our_stars.jpg', 'description' => 'Lorem ipsum dolor sit amet,
				consectetur adipisicing elit. Excepturi nesciunt error, 
				id, eaque aut quia quasi omnis, dignissimos commodi vero eveniet 
				tempore blanditiis molestias voluptatem, iusto. Sit, debitis consequatur non'), array('id' => 2, 'title' => 'Rekayasa Web', 'author' => "Janner Simarmata", 'publisher' => 'Andi Publisher', 'category' => 'Computing & Internet', 'date' => '2012', 'stock' => 7, 'cover' => 'rekayasa_web.jpg', 'description' => 'Lorem ipsum dolor sit amet, 
				consectetur adipisicing elit. Excepturi nesciunt error, 
				id, eaque aut quia quasi omnis, dignissimos commodi vero eveniet 
				tempore blanditiis molestias voluptatem, iusto. Sit, debitis consequatur non'), array('id' => 3, 'title' => 'Ketika Menikah Jadi Pilihan', 'author' => 'ADIL ABDUL MUNIM ABU ABBAS', 'publisher' => 'ALMAHIRA', 'category' => 'Religion', 'date' => '2008', 'stock' => 5, 'cover' => 'ketika_menikah_jadi_pilihan.jpg', 'description' => 'Lorem ipsum dolor sit amet, 
				consectetur adipisicing elit. Excepturi nesciunt error, 
				id, eaque aut quia quasi omnis, dignissimos commodi vero eveniet 
				tempore blanditiis molestias voluptatem, iusto. Sit, debitis consequatur non'), array('id' => 4, 'title' => '500 Rahasia Cantik Alami', 'author' => 'Author Example', 'publisher' => 'Publisher Example', 'category' => 'Health', 'date' => '2013', 'stock' => 5, 'cover' => '500_rahasia_cantik_alami_bebas_jerawat.jpg', 'description' => 'Lorem ipsum dolor sit amet,
				consectetur adipisicing elit. Excepturi nesciunt error,
				id, eaque aut quia quasi omnis, dignissimos commodi vero eveniet
				tempore blanditiis molestias voluptatem, iusto. Sit, debitis consequatur non'), array('id' => 5, 'title' => 'Anak Anak Cemerlang', 'author' => 'Author Example', 'publisher' => 'Publisher Example', 'category' => 'Education', 'date' => '2013', 'stock' => 5, 'cover' => 'anak_anak_cemerlang.jpg', 'description' => 'Lorem ipsum dolor sit amet,
				consectetur adipisicing elit. Excepturi nesciunt error,
				id, eaque aut quia quasi omnis, dignissimos commodi vero eveniet
				tempore blanditiis molestias voluptatem, iusto. Sit, debitis consequatur non'), array('id' => 6, 'title' => 'Dashyatnya Pengobatan Hewan', 'author' => 'Author Example', 'publisher' => 'Publisher Example', 'category' => 'medical', 'date' => '2013', 'stock' => 5, 'cover' => 'dashyatnya_pengobatan_hewan.jpg', 'description' => 'Lorem ipsum dolor sit amet,
				consectetur adipisicing elit. Excepturi nesciunt error,
				id, eaque aut quia quasi omnis, dignissimos commodi vero eveniet
				tempore blanditiis molestias voluptatem, iusto. Sit, debitis consequatur non'), array('id' => 7, 'title' => 'Food Photography', 'author' => 'Author Example', 'publisher' => 'Publisher Example', 'category' => 'Photography', 'date' => '2013', 'stock' => 5, 'cover' => 'food_photography_dari_foto_biasa_jadi_luar_biasa.jpg', 'description' => 'Lorem ipsum dolor sit amet,
				consectetur adipisicing elit. Excepturi nesciunt error,
				id, eaque aut quia quasi omnis, dignissimos commodi vero eveniet
				tempore blanditiis molestias voluptatem, iusto. Sit, debitis consequatur non'), array('id' => 8, 'title' => 'Jus Sehat Golongan Darah AB', 'author' => 'Author Example', 'publisher' => 'Publisher Example', 'category' => 'Health', 'date' => '2013', 'stock' => 5, 'cover' => 'jus_sehat_golongan_darah_ab.jpg', 'description' => 'Lorem ipsum dolor sit amet,
				consectetur adipisicing elit. Excepturi nesciunt error,
				id, eaque aut quia quasi omnis, dignissimos commodi vero eveniet
				tempore blanditiis molestias voluptatem, iusto. Sit, debitis consequatur non'), array('id' => 9, 'title' => 'Karya Tulis Ilmiah', 'author' => 'Author Example', 'publisher' => 'Publisher Example', 'category' => 'Education', 'date' => '2013', 'stock' => 5, 'cover' => 'karya_tulis_ilmiah.jpg', 'description' => 'Lorem ipsum dolor sit amet,
				consectetur adipisicing elit. Excepturi nesciunt error,
				id, eaque aut quia quasi omnis, dignissimos commodi vero eveniet
				tempore blanditiis molestias voluptatem, iusto. Sit, debitis consequatur non'));
        foreach ($books as $book) {
            App\Book::create($book);
        }
    }
Ejemplo n.º 5
0
 public function postCreate(Request $request)
 {
     $this->validate($request, ['title' => 'required|min:5', 'author' => 'required|min:5', 'cover' => 'required|url', 'published' => 'required|min:4']);
     // Code here to enter book into the database
     $book = new \App\Book();
     $book->title = $request->title;
     $book->author = $request->author;
     $book->cover = $request->cover;
     $book->published = $request->published;
     $book->purchase_link = $request->purchase_link;
     $book->save();
     // Confirm book was entered:
     //return 'Process adding new book: '.$request->input('title');
     //return view()
     \Session::flash('flash_message', 'Your book was added!');
     return redirect('/books/create');
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create(Request $request)
 {
     $title = $request->input('title');
     $auth = $request->input('author');
     $sum = $request->input('summary');
     $rate = $request->input('rating');
     #create a new book with data submitted
     $book = new \App\Book();
     $book->title = $title;
     $book->author = $auth;
     $book->summary = $sum;
     $book->save();
     #attach rating to book table
     $ratingBook = new \App\Rating();
     $ratingBook->rating = $rate;
     $ratingBook->save();
     $book->ratings()->attach($ratingBook);
     Session::flash('message', 'Successfully created book!');
     $books = \App\Book::all();
     return view('/books/member')->with('books', $books);
 }
Ejemplo n.º 7
0
Route::get('/backend/', ['middleware' => 'auth.role:4', function () {
    $books = App\Book::where('active', 0)->get();
    $users = App\user::where('active', 0)->get();
    return view('admin/home', ['books' => $books, 'users' => $users]);
}]);
Route::get('/backend/books', ['middleware' => 'auth.role:4', function () {
    $books = App\Book::all();
    return view('admin/listBooks', ['books' => $books]);
}]);
Route::get('/backend/users', ['middleware' => 'auth.role:4', function () {
    $users = App\user::all();
    return view('admin/listUsers', ['users' => $users]);
}]);
Route::get('/backend/book/status/{id}', ['middleware' => 'auth.role:4', function ($id) {
    try {
        $books = App\Book::where('id', $id)->get();
        foreach ($books as $book) {
            $book->active == 1 ? $book->active = 0 : ($book->active = 1);
            $book->save();
        }
    } catch (\Exception $e) {
        return back();
    }
    return back();
}]);
//user
Route::get('/user/review/{user}/{payment}/{book}', ['middleware' => 'auth.role:1', function ($user, $payment, $book) {
    $user = \App\User::find($user);
    return view('user/review', ['user' => $user, 'payment' => $payment, 'book' => $book]);
}]);
Route::post("/user/review", ['middleware' => 'auth.role:1', 'uses' => 'UserController@review']);
Ejemplo n.º 8
0
<?php

require_once 'vendor/autoload.php';
define('BOOKS_NUMBER', 100);
$moreShelf = new \App\MoreBookShelf();
$petShelf = new \App\PetBookShelf();
$faker = Faker\Factory::create('ja_JP');
$faker->addProvider(new \Library\BookFaker($faker));
for ($i = 0; $i < BOOKS_NUMBER; $i++) {
    $book = new \App\Book();
    $book->setIsbn($faker->isbnStr);
    $book->setTitle($faker->title);
    $book->setAuthor($faker->name);
    $moreShelf->add($book);
    $petShelf->add($book);
}
$moreShelf->save();
$petShelf->save();
Ejemplo n.º 9
0
 /**
  * Responds to requests to POST /books/create
  */
 public function postCreate(Request $request)
 {
     // validation
     $this->validate($request, ['title' => 'required|min:5', 'cover' => 'required|url', 'published' => 'required|min:4']);
     // Code here to enter into the database
     // new Book object
     // mass-assignment
     $book = new \App\Book();
     $book->title = $request->title;
     //$book->author = $request->author;
     $book->author_id = $request->author;
     $book->user_id = \Auth::id();
     $book->cover = $request->cover;
     $book->published = $request->published;
     $book->purchase_link = $request->purchase_link;
     $book->save();
     // Confirm book was entered:
     //return 'Process adding new book' . $request->input('title');
     \Session::flash('flash_message', 'Your book was added!');
     return redirect('/books');
 }
Ejemplo n.º 10
0
 /**
  * Responds to requests to POST /books/create
  */
 public function postCreate(Request $request)
 {
     $this->validate($request, ['title' => 'required|min:5', 'cover' => 'required|url', 'published' => 'required|min:4']);
     # Enter book into the database
     $book = new \App\Book();
     $book->title = $request->title;
     $book->author_id = $request->author;
     $book->user_id = \Auth::id();
     # <--- NEW LINE
     $book->cover = $request->cover;
     $book->published = $request->published;
     $book->purchase_link = $request->purchase_link;
     $book->save();
     # Add the tags
     if ($request->tags) {
         $tags = $request->tags;
     } else {
         $tags = [];
     }
     $book->tags()->sync($tags);
     # Done
     \Session::flash('flash_message', 'Your book was added!');
     return redirect('/books');
 }
Ejemplo n.º 11
0
<?php

/*layout chung trong project 
 *gom co 
 		header
 			--banner
 			--navigator
 		body
 			--sidebar --content
 		footer	
*/
$books = App\Book::select('title', 'isbn')->get();
$authors = App\Author::select('name')->get();
$publishers = App\Publisher::select('name')->get();
$data = array();
foreach ($books as $book) {
    array_push($data, $book->isbn);
    array_push($data, $book->title . ' - tên sách');
}
foreach ($authors as $author) {
    array_push($data, $author->name . ' - tác giả');
}
foreach ($publishers as $publisher) {
    array_push($data, $publisher->name . ' - nhà xuất bản');
}
echo "<script>var availableTags = " . json_encode($data) . ";</script>";
?>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
Ejemplo n.º 12
0
<?php

/*
|--------------------------------------------------------------------------
| 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('/', function () {
    return view('welcome');
});
Route::get('/mongo', function () {
    /*App\Book::create(['name' => 'MongoDB Pro', 'author' => 'Dwight Merriman']);*/
    /*$book = App\Book::find('565e8d2d071a58a5788b4570');
    	$book->author = 'Misko Hevery';
    	$book->name = 'Fundamentals Of Angular JS';
    	$book->save();*/
    //$book->delete();
    $books = App\Book::all()->toArray();
    echo '<pre>';
    print_r($books);
    return 'Hello Sir!!';
});
Ejemplo n.º 13
0
Route::get('login', ['uses' => 'LoginController@index', 'middleware' => 'login']);
Route::group(['middleware' => 'admin', 'prefix' => 'admin'], function () {
    Route::get('/', 'AdminController@index');
    Route::resource('users', 'UserController');
    Route::get('profile', 'UserController@editProfile');
    Route::put('profile/update/{id}', ['as' => 'profile.admin', 'uses' => 'UserController@updateProfile']);
    Route::resource('books', 'BookController');
    Route::get('users/reset/{id}', 'UserController@reset');
});
Route::group(['middleware' => 'operator', 'prefix' => 'operator'], function () {
    Route::get('/', ['as' => 'op', 'uses' => 'OperatorController@index']);
    Route::resource('users', 'UserController');
    Route::get('profile', 'UserController@editProfile');
    Route::put('profile/update/{id}', ['as' => 'profile.operator', 'uses' => 'UserController@updateProfile']);
    Route::get('users/reset/{id}', 'UserController@reset');
    Route::resource('borrow', 'BorrowController');
    Route::resource('books', 'BookController');
    Route::get('order', 'OrderController@index');
    Route::get('order/{id}', 'OrderController@process');
    Route::resource('transactions', 'TransactionController');
});
Route::group(['middleware' => 'member'], function () {
    Route::get('books/order/{id}', ['as' => 'order', 'uses' => 'OrderController@order']);
    Route::put('/profile/update/{id}', ['as' => 'profile.member', 'uses' => 'UserController@updateName']);
    Route::put('users/{id}', 'UserController@updateProfile');
});
Route::get('image/{id}', function ($id) {
    $book = App\Book::find($id);
    $img = Image::make(asset('images/cover/' . $book->cover))->resize(268, 249);
    return $img->response('jpg');
});
Ejemplo n.º 14
0
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
    return view('welcome');
});
Route::get('book_create', function () {
    echo "Creating the records....";
    $title = 'Eze goes to College';
    $pages_count = 800;
    $price = 15.5;
    $description = 'This is a very interesting book about Eze going to College and killing it';
    $author_id = 1;
    $publisher_id = 1;
    // Method 1 of inserting records into the database via a Model - Mass Assignment
    $book = new \App\Book(['title' => $title, 'pages_count' => $pages_count, 'price' => $price, 'description' => $description, 'author_id' => $author_id, 'publisher_id' => $publisher_id]);
    $book->save();
    // You have to call the save method here if using Method 1 technique
    // Use either of them to insert records into the database
    // For security issues it won't allow you create those records just like that, so...
    // Make sure you have properties $fillable or $guarded in your Model
    // e.g protected $fillable  = ['title','pages_count','price','description','author_id','publisher_id']
    // Method 2 of inserting records into the database via a Model - Mass Assignment
    $book = \App\Book::create(['title' => $title, 'price' => $price, 'pages_count' => $pages_count, 'description' => $description, 'author_id' => $author_id, 'publisher_id' => $publisher_id]);
    echo "Done....";
});
Route::get('book_get_all', function () {
    return \App\Book::all();
});
Route::get('book_get_2', function () {
    return \App\Book::findOrFail(2);