PHP code example of anik / repottern

1. Go to this page and download the library: Download anik/repottern library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

anik / repottern example snippets



// Repository
class UserRepository extends BaseRepository
{
	public function model ()
	{
		return User::class;
	}	
	
	protected function findUserWithWildCard()
	{
	    return $this->where('username', 'LIKE', "%n%")->get();
	}
}


// From controller
class HomeController extends Controller
{
    public function controllerMethod(UserRepository $repository)
    {
        # return $repository->with('role')->get();
        # return $repository->paginate(10);
        # return $repository->find(10);
        # return $repository->findUserWithWildCard();
        
        # return UserRepository::with('role')->get();
        # return UserRepository::paginate(10);
        # return UserRepository::find(10);
        # return UserRepository::findUserWithWildCard();
        
    }
}