Created
July 9, 2019 14:39
-
-
Save didotsonev/c8b3cc9d9f48f923e3c6dd849a284913 to your computer and use it in GitHub Desktop.
Revisions
-
didotsonev created this gist
Jul 9, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ public function user() { return $this->belongsTo('App\Models\User'); } public function projects() { return $this->hasMany('App\Models\Project'); } public function pictures() { return $this->hasMany('App\Models\Picture'); } public function noProjectPictures() { return $this->pictures()->whereNull('project_id'); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ public function company() { return $this->belongsTo('App\Models\Company'); } public function project() { return $this->belongsTo('App\Models\Project'); } public function withoutProject($comapnyId) { return $this->where('comapny_id', $comapny_id)->whereNull('project_id') } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ public function company() { return $this->belongsTo('App\Models\Company'); } public function pictures() { return $this->hasMany('App\Models\Pictures'); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ public function company() { return $this->hasOne('App\Models\Company'); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ Auth:user()->company->noProjectPictures(); -----OR----- $pictures = new Picture(); $pictures->withoutProject(Auth::user()->company->id);