<commit_before><?php

namespace App\Http\Controllers;

use App\Models\Book;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

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

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $this->validate($request, [
            'book_title' => 'required|string|max:500|unique:books,title',
            'book_author_name' => 'required|string',
            'book_nb_pages' => 'required|integer',
        ]);

        $book = Book::create([
            'title' => $request->input('book_title'),
            'author' => $request->input('book_author_name'),
            'num_pages' => $request->input('book_nb_pages'),
        ]);

        return response(['book' => $book], 201)->header('Location', '/api/book/'.$book->id);
    }

    /**
     * Display the specified resource.
     *<commit_msg>return all books on get resources<commit_after><?php

namespace App\Http\Controllers;

use App\Models\Book;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class BooksController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return response(['books' => Book::all()], 200);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $this->validate($request, [
            'book_title' => 'required|string|max:500|unique:books,title',
            'book_author_name' => 'required|string',
            'book_nb_pages' => 'required|integer',
        ]);

        $book = Book::create([
            'title' => $request->input('book_title'),
            'author' => $request->input('book_author_name'),
            'num_pages' => $request->input('book_nb_pages'),
        ]);

        return response(['book' => $book], 201)->header('Location', '/api/book/'.$book->id);
    }

    /**
     * Display the specified resource.
     *
{'fraction_non_alphanumeric': 0.15328169588259274, 'fraction_numerical': 0.006114961271911945, 'mean_word_length': 2.398891966759003, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1200580', 'n_tokens_mistral': 723, 'n_tokens_neox': 727, 'n_words': 141}