Laravel Classroom image

CiliSp
 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|1 | 2 | 3 | 4 | 5 | 6 | 7 | 8|Last
Lessons:-The Blog Tutorial

15.3 Eloquent Models
Right, you know exactly how to create Eloquent models, so let’s just have a look at the source.
1 <?php
2
3 class User extends Eloquent
4 {
5 public function posts()
6 {
7 return $this->has_many('Post');
8 }
9 }
10
11 class Post extends Eloquent
12 {
13 public function author()
14 {
15 return $this->belongs_to('User', 'author_id');
16 }
17 }
Nice and simple, we have our User object which has_many posts, and our Post object which
belongs_to a user.

 
 
 

CiliSp

Skills    Laravel

Qualifications :-
Location :-,,,
Description:-
Explore
 

  Students (0)