mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-31 15:24:31 +03:00
Initial commit
This commit is contained in:
50
app/Repos/BookRepo.php
Normal file
50
app/Repos/BookRepo.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php namespace Oxbow\Repos;
|
||||
|
||||
use Oxbow\Book;
|
||||
|
||||
class BookRepo
|
||||
{
|
||||
|
||||
protected $book;
|
||||
|
||||
/**
|
||||
* BookRepo constructor.
|
||||
* @param $book
|
||||
*/
|
||||
public function __construct(Book $book)
|
||||
{
|
||||
$this->book = $book;
|
||||
}
|
||||
|
||||
public function getById($id)
|
||||
{
|
||||
return $this->book->findOrFail($id);
|
||||
}
|
||||
|
||||
public function getAll()
|
||||
{
|
||||
return $this->book->all();
|
||||
}
|
||||
|
||||
public function getBySlug($slug)
|
||||
{
|
||||
return $this->book->where('slug', '=', $slug)->first();
|
||||
}
|
||||
|
||||
public function newFromInput($input)
|
||||
{
|
||||
return $this->book->fill($input);
|
||||
}
|
||||
|
||||
public function countBySlug($slug)
|
||||
{
|
||||
return $this->book->where('slug', '=', $slug)->count();
|
||||
}
|
||||
|
||||
public function destroyById($id)
|
||||
{
|
||||
$book = $this->getById($id);
|
||||
$book->delete();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user