Skip to content

Comments

Login + Logout + Eloquent#1

Open
minhquanghapo wants to merge 3 commits intoft/CRUDfrom
LoginLogoutEloquent
Open

Login + Logout + Eloquent#1
minhquanghapo wants to merge 3 commits intoft/CRUDfrom
LoginLogoutEloquent

Conversation

@minhquanghapo
Copy link
Owner

Problem về phần Eloquent là nếu xét một quan hệ thì có cần phải viết eloquent cho cả 2 đối tượng trong quan hệ đó ko. Ví dụ A và B là quan hệ one many. Thì bên A viết là hasMany()... bên B cũng viết là belongstoMany() ????

@thanhnt07-vn
Copy link

@minhquang97 : ở model nào e viết eloquent relation thì có thể sử dụng orm để query relation phía bên model đó, ko viết 1 bên dùng đc cả 2 bên đc. ví dụ e có 2 model là User + Post có quan hệ 1-n, nếu ở model User có :

public function posts()
{
    // todo
}

như vậy thì chỉ dùng đc 1 chiều get user's post bằng $user->posts,

@minhquanghapo
Copy link
Owner Author

@thanhnt-hapo em đã hiểu rồi ạ.

@@ -0,0 +1,25 @@
<?php
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@minhquang97 đẩy cả file test lên à e ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ em quên không xóa

@@ -23,8 +23,9 @@ public function authorize()
public function rules()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@minhquang97 cái này là dùng cho cả createupdate à e ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

đúng rồi a. Em dùng cái này cho cả 2 luôn.


class Classes extends Model
{
protected $table = "classes";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@minhquang97 tên Class để ở dạng số ít thôi e, k cần khai báo $table khi e để tên class ở dạng số ít, tên bảng ở dạng số nhiều

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cái này em lỡ tay đặt tên classes rồi nên em phải định nghĩa table. em sẽ sửa lại.

{
protected $table = "classes";
protected $fillable = [
'id','teacher_id','subject_id','semester'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@minhquang97 thêm space sau ,

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okey a


public function teacher()
{
return $this->belongsto('App\Model\Teacher');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@minhquang97 khi viết relation các class viết theo form Teacher::class

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nghĩa là App\Model\Teacher::class

@@ -4,11 +4,10 @@

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@minhquang97 model này đang dùng cho student à e ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

không ạ. cái này là tài khoản để user để học sinh login vào xem thông tin, điểm cá nhân, với em dự định sẽ tạo thêm một admin để quản lý học sinh nữa.

composer.json Outdated
"optimize-autoloader": true
}
,
"repositories": [
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@minhquang97 format đang sai


<div class="form-group">
<div class="col-md-8 col-md-offset-4">
<a href="{{url('/redirect')}}" class="btn btn-primary">Login with Facebook</a>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@minhquang97 Login sao dùng url này nhỉ ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

em sử dụng trong route Route::get('/redirect', 'SocialAuthFacebookController@redirect');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants