44
55use Illuminate \Database \Eloquent \Model ;
66use Illuminate \Database \Eloquent \SoftDeletes ;
7- use Illuminate \Support \Facades \Auth ;
87
98class Article extends Model
109{
@@ -42,7 +41,8 @@ class Article extends Model
4241 * @param $query
4342 * @return mixed
4443 */
45- public function scopePublished ($ query ) {
44+ public function scopePublished ($ query )
45+ {
4646 return $ query ->where ([
4747 'published ' => true
4848 ]);
@@ -55,7 +55,8 @@ public function scopePublished($query) {
5555 * @param $user_id
5656 * @return mixed
5757 */
58- public function scopeMine ($ query , $ user_id ) {
58+ public function scopeMine ($ query , $ user_id )
59+ {
5960 return $ query ->where ('user_id ' , $ user_id );
6061 }
6162
@@ -64,7 +65,8 @@ public function scopeMine($query, $user_id) {
6465 *
6566 * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
6667 */
67- public function user () {
68+ public function user ()
69+ {
6870 return $ this ->belongsTo (User::class);
6971 }
7072
@@ -73,7 +75,8 @@ public function user() {
7375 *
7476 * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
7577 */
76- public static function loadAll () {
78+ public static function loadAll ()
79+ {
7780 return static ::latest ()
7881 ->paginate ();
7982 }
@@ -84,7 +87,8 @@ public static function loadAll() {
8487 * @param $user_id
8588 * @return mixed
8689 */
87- public static function loadAllMine ($ user_id ) {
90+ public static function loadAllMine ($ user_id )
91+ {
8892 return static ::latest ()
8993 ->mine ($ user_id )
9094 ->paginate ();
@@ -95,8 +99,9 @@ public static function loadAllMine($user_id) {
9599 *
96100 * @return mixed
97101 */
98- public static function loadAllPublished () {
99- return static ::with (['user ' => function ($ query ) {
102+ public static function loadAllPublished ()
103+ {
104+ return static ::with (['user ' => function ($ query ) {
100105 $ query ->select ('id ' , 'name ' );
101106 }])
102107 ->latest ()
@@ -110,9 +115,10 @@ public static function loadAllPublished() {
110115 * @param $id
111116 * @return mixed
112117 */
113- public static function loadPublished ($ slug ) {
118+ public static function loadPublished ($ slug )
119+ {
114120 return static ::with ([
115- 'user ' => function ($ query ) {
121+ 'user ' => function ($ query ) {
116122 $ query ->select ('id ' , 'name ' );
117123 }
118124 ])
0 commit comments