for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the site package.
*
* (c) Mohamed Alsharaf <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tinyissue\Extensions\Model;
use Illuminate\Database\Eloquent\Collection;
use Tinyissue\Contracts\Repository\Role\RoleRepository;
/**
* FetchRoleTrait is trait class contains method to set and fetch roles.
* @author Mohamed Alsharaf <[email protected]>
trait FetchRoleTrait
{
* Collection of all tags.
* @var Collection
protected $roles = null;
* @var RoleRepository
protected $roleRepository;
public function setRoleRepository(RoleRepository $roleRepository)
$this->roleRepository = $roleRepository;
return $this;
}
* @return TagRepository
public function getRoleRepository()
if (is_null($this->roleRepository) && property_exists($this, 'app')) {
$this->roleRepository = $this->app->make(RoleRepository::class);
app
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
return $this->roleRepository;
* @return Collection
protected function getRoleNameDropdown()
return $this->getRoleRepository()->getNameDropdown();
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: