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
feat(profile): add user chapters tree #40
Conversation
38184df
to
17fe733
Compare
|
||
public function getIsReadAttribute() | ||
{ | ||
return $this->user->where('id', Auth::user()->id)->count() > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вспоминаем MVC и отношение понятие аутентификации по отношению к модели.
use App\User; | ||
|
||
class UserController extends Controller | ||
{ | ||
public function show(string $name) | ||
{ | ||
$user = User::where('name', $name)->firstOrFail(); | ||
|
||
$allChapters = Chapter::with('user')->get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Такие штуки должны доставаться через связи
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
так а это не доставание, а просто загрузка данных для жадной загрузки
https://laravel.com/docs/6.0/eloquent-relationships#eager-loading
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А ок, но возникает вопрос, откуда у chapter может быть понятие "пользователь"? Главы сами по себе не привязаны к пользователям напрямую.
@@ -0,0 +1,3 @@ | |||
.chapters-tree { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Кастомных стилей не надо, в бутстрапе все это есть
tests/Unit/Model/ChapterTest.php
Outdated
use App\User; | ||
use Tests\TestCase; | ||
|
||
class ChapterTest extends TestCase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вот смотри, куча кода ради одного примитивного метода. Правда метод все равно написан неправильно.
17fe733
to
dc6877b
Compare
dc6877b
to
9c5bd92
Compare
На странице профиля добавил вывод всех глав, если глава прочитана пользователем, то чекбокс нажат