Skip to content

Instantly share code, notes, and snippets.

@didotsonev
Created July 9, 2019 14:39
Show Gist options
  • Save didotsonev/c8b3cc9d9f48f923e3c6dd849a284913 to your computer and use it in GitHub Desktop.
Save didotsonev/c8b3cc9d9f48f923e3c6dd849a284913 to your computer and use it in GitHub Desktop.
pictures without project, how to get them in index.blade.php?
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');
}
Auth:user()->company->noProjectPictures();
-----OR-----
$pictures = new Picture();
$pictures->withoutProject(Auth::user()->company->id);
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')
}
public function company()
{
return $this->belongsTo('App\Models\Company');
}
public function pictures()
{
return $this->hasMany('App\Models\Pictures');
}
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