Created
July 9, 2019 14:39
-
-
Save didotsonev/c8b3cc9d9f48f923e3c6dd849a284913 to your computer and use it in GitHub Desktop.
pictures without project, how to get them in index.blade.php?
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 characters
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 characters
Auth:user()->company->noProjectPictures(); | |
-----OR----- | |
$pictures = new Picture(); | |
$pictures->withoutProject(Auth::user()->company->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 characters
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 characters
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 characters
public function company() | |
{ | |
return $this->hasOne('App\Models\Company'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment