All Projects → amin3536 → Anar

amin3536 / Anar

Licence: MIT license
laravel package : artisan commands for create Repository and provider

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to Anar

SQLBuilder.Core
.NET Standard 2.1、.NET 5、.NET 6 版本SQLBuilder,Expression表达式转换为SQL语句,支持SqlServer、MySql、Oracle、Sqlite、PostgreSql;基于Dapper实现了不同数据库对应的数据仓储Repository;
Stars: ✭ 85 (+240%)
Mutual labels:  repository
dapper-repositories
CRUD for Dapper
Stars: ✭ 523 (+1992%)
Mutual labels:  repository
terraform-module-versions
CLI tool that checks Terraform code for module updates. Single binary, no dependencies. linux, osx, windows. #golang #cli #terraform
Stars: ✭ 143 (+472%)
Mutual labels:  repository
git-pull-or-clone
Ensure a git repo exists on disk and that it's up-to-date
Stars: ✭ 46 (+84%)
Mutual labels:  repository
ApiCenter
A repository for all your API specifications
Stars: ✭ 26 (+4%)
Mutual labels:  repository
repo-card
😎 showcase repositories on your website 🤘!
Stars: ✭ 141 (+464%)
Mutual labels:  repository
docker-debian-repository
A local repository for publishing deb files for use with apt.
Stars: ✭ 49 (+96%)
Mutual labels:  repository
laravel-repository
Repository pattern implementation for Laravel
Stars: ✭ 49 (+96%)
Mutual labels:  repository
dradis-docker
A Docker image with Dradis: A collaboration and reporting platform for IT security experts.
Stars: ✭ 13 (-48%)
Mutual labels:  repository
devliver
Your private self hosted composer repository with user management
Stars: ✭ 50 (+100%)
Mutual labels:  repository
eloquent-repository
Repository pattern for Eloquent ORM with focus in cache.
Stars: ✭ 30 (+20%)
Mutual labels:  repository
alfresco-simple-content-stores
Addon to provide a set of common content store implementations and easy-to-use configuration (no Spring config)
Stars: ✭ 40 (+60%)
Mutual labels:  repository
aggregate-persistence-sample
No description or website provided.
Stars: ✭ 25 (+0%)
Mutual labels:  repository
gradle-git-versioning-plugin
This extension will set project version, based on current Git branch or tag.
Stars: ✭ 44 (+76%)
Mutual labels:  repository
ioBroker.repositories
Repositories for ioBroker project
Stars: ✭ 55 (+120%)
Mutual labels:  repository
python-tuf
Python reference implementation of The Update Framework (TUF)
Stars: ✭ 1,425 (+5600%)
Mutual labels:  repository
repology-rules
Package normalization ruleset for Repology
Stars: ✭ 67 (+168%)
Mutual labels:  repository
repository-beta
BETA - Home Assistant Community Add-ons
Stars: ✭ 25 (+0%)
Mutual labels:  repository
artisan-shortcuts
🍰 Register shortcuts to execute multiple artisan commands
Stars: ✭ 56 (+124%)
Mutual labels:  artisan-command
GraphQL.RepoDB
A set of extensions for working with HotChocolate GraphQL and Database access with micro-orms such as RepoDb (or Dapper). This extension pack provides access to key elements such as Selections/Projections, Sort arguments, & Paging arguments in a significantly simplified facade so this logic can be leveraged in the Serivces/Repositories that enca…
Stars: ✭ 25 (+0%)
Mutual labels:  repository

Anar

Latest Version on Packagist Total Downloads Build Status StyleCI

Anar is artisan command to create repository for your amazing laravel app easy peasy . Take look at contributing.md to see a to do list.

if you don't know about Repository pattern read this link

Installation

Via Composer

$ composer require amin3520/anar

Change log

Please see the changelog for more information on what has changed recently.

command

$ php artisan make:repository name  --m=model_name --imp 
  #sample php artisan make:repository UserRepository --m=User --imp 
  #sample2 php artisan make:repository UserRepository --m='\App\User' --imp 

name is your name Repository ,

--moption is model name that use in repo and it is necessary input , now u can also pass your address model in string like '\App\User'

--imp create interface for your repo

first run of command create base files and directory ,you can see them below

|--Providers
|       |--RepositoryServiceProvider.php
|
|--Repositories
|       |--BaseRepository.php
|       |--BaseRepositoryImp.php
|       |//and other your repoitorys

Configuration

if you want inject your repositories in some constructor like controllers ,add repo name in $names in Providers/RepositoryServiceProvider.php and add \App\Providers\RepositoryServiceProvider::class in providers in config\app.php

  /**
     * Register RepositoryServiceProvider  .
     * provide your repository and inject it any where below your app directoy, like in to your controller's app if you want to use it
     * @return void
     */
    public function register()
    {
         $names = [
               //add Begin your repository name here   like -> 'UserRepository',
            ];

            foreach ($names as $name) {
                $this->app->bind(
                    "App\\Repositories\\{$name}",
                    "App\\Repositories\\{$name}");
            }


    }

Usage

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
    private $userRepo;

    /**
     * Controller constructor.
     *inject repo by service provider
     */
    public function __construct(UserRepositoryImp $repositoryImp)
    {
        $this->userRepo=$repositoryImp;
        //now u can use it
    }

    public function updateName(Request $request)
    {
        $this->userRepo->update(['name'=>'amin'],auth::id());
    }
}

BaseMethods

Base repository has some useful method you can use theme

interface BaseRepositoryImp
{
        public function create(array $attributes);
        public function update(array $attributes, int $id);
        public function all($columns = array('*'), string $orderBy = 'id', string $sortBy = 'desc');
        public function find(int $id);
        public function findOneOrFail(int $id);
        public function findBy(array $data);
        public function findOneBy(array $data);
        public function findOneByOrFail(array $data);
        public function paginateArrayResults(array $data, int $perPage = 50);
        public function delete(int $id);
        public function findWhere($where, $columns = ['*'], $or = false);
        public function with(array $relations);
}

methods

Contributing

Please see contributing.md for details and a todolist.

Task list:

  • add Test
  • add dynamic directory option
  • add dynamically pickUp address's model
  • add cache option

License

MIT License. Please see the license file for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].