Skip to content

Instantly share code, notes, and snippets.

@didotsonev
Created July 9, 2019 14:39
Show Gist options
  • Select an option

  • Save didotsonev/c8b3cc9d9f48f923e3c6dd849a284913 to your computer and use it in GitHub Desktop.

Select an option

Save didotsonev/c8b3cc9d9f48f923e3c6dd849a284913 to your computer and use it in GitHub Desktop.

Revisions

  1. didotsonev created this gist Jul 9, 2019.
    19 changes: 19 additions & 0 deletions Comapny.php
    Original 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');
    }
    14 changes: 14 additions & 0 deletions Picture
    Original 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')
    }
    9 changes: 9 additions & 0 deletions Project.php
    Original 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');
    }
    4 changes: 4 additions & 0 deletions User.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    public function company()
    {
    return $this->hasOne('App\Models\Company');
    }
    6 changes: 6 additions & 0 deletions index.blade.php
    Original 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);