Database Repository / PHP Repository / Laravel Repository

Related tags

Laravel php laravel lumen
Overview

Database Repository / PHP Repository / Laravel Repository

Installation

Use following command to add this package to composer development requirement.

composer require nanvaie/database-repository --dev

Setup for Laravel

Before publishing assets, add REPOSITORY_PHP_VERSION variable to .env and set it to your version of choosing. Supported values are: 8.0, 7.4 (Default is 8.0).

Then run following command in console to publish necessary assets in your project directory.

php artisan vendor:publish --provider=Nanvaie\DatabaseRepository\DatabaseRepositoryServiceProvider

Setup for Lumen

Navigate to app.php in bootstrap folder and add following line after service providers registrations:

// snip
if ($app->environment('local', 'testing')) {
    $app->register(Nanvaie\DatabaseRepository\DatabaseRepositoryServiceProvider::class);
}
// snip

Copy repository.php to project config folder located at project root.

Note: Make sure to run composer dump-autoload after these changes.

Usage

List of artisan commands:

Command Inputs Options Description
repository:make-entity table_name -f, -d, -k, -g Create new Entity
repository:make-factory table_name -f, -d, -g Create new Factory
repository:make-resource table_name -f, -d, -k, -g Create new Resource
repository:make-interface-repository table_name -f, -d, -k, -g Create new Repository Interface
repository:make-repository table_name -f, -d, -g Create new Base Repository
repository:make-mysql-repository table_name -f, -d, -k, -g Create new MySql Repository class
repository:make-redis-repository table_name -f, -d, -k, -g Create new Redis Repository class
repository:make-all table_names -f, -d, -k, -g Run all of the above commands

Options Explanation

  • -f|--force: Force commands to override existing files.
  • -d|--delete: Delete already created files.
  • -k|--foreign-keys: Try to detect foreign keys of table.
  • -g|--add-to-git: Add created files to git repository.

Example 1. Create new Entity for a table named 'users'.

php artisan command:make-entity users

Example 2. Create all necessary classes for two tables named 'users' and 'customers' with enabled foreign key option.

php artisan command:make-all-repository users customers -k
You might also like...
Declare database migrations and factory definitions inside Laravel models.

Lucid This package allows you to declare database migrations and factory definitions inside of your Laravel models. Running the lucid:migrate command

Easily integrate single-database multi tenant features into your Laravel application
Easily integrate single-database multi tenant features into your Laravel application

Laravel Tenant Aware Easily integrate single-database multi tenant features into your Laravel application. Installation You can install the package vi

Laravel package for manage your URL redirects in database or other sources to get better SEO results

Laravel 8 and 9 package to manage URL redirections inside your Laravel application using different data sources. It allows a better SEO support for your Laravel site.

A query database collection for use with Laravel Pipeline

A query database collection for use with Laravel Pipeline This package contains a collection of class that can be used with Laravel Pipeline. Let's se

PHP API for GeoIP2 webservice client and database reader

GeoIP2 PHP API Description This package provides an API for the GeoIP2 and GeoLite2 web services and databases. Install via Composer We recommend inst

Validate PHP database migration files for compliance with best practices. Ensure db migrations are irreversible.
Validate PHP database migration files for compliance with best practices. Ensure db migrations are irreversible.

PHP DB Migration Validator Introduction In modern PHP frameworks such as Symfony and Laravel, migrations usually have up and down methods. In up metho

PHP API for GeoIP2 webservice client and database reader

GeoIP2 PHP API Description This package provides an API for the GeoIP2 and GeoLite2 web services and databases. Install via Composer We recommend inst

Clean up and prevent empty meta from being saved for Job, Company, or Resume listings in database

=== Empty Meta Cleanup for WP Job Manager === Contributors: tripflex Tags: wp job manager, meta, cleanup, wpjobmanager Requires at least: 5.2 Tested u

The query filter bundle allows you to filter data from QueryBuilder and the Database.
The query filter bundle allows you to filter data from QueryBuilder and the Database.

The query filter bundle allows you to filter data from QueryBuilder and the Database. you can filter multiple columns at the same time and also you can filter relation fields with two-level deep and without any join in your query builder.

Comments
  • When generating nullable Entity set default value to null

    When generating nullable Entity set default value to null

    When using Entity in Repository there is an Exception "must not be accessed before initialization" so in order to fix this Exception we have to set null in all nullable fields When generating a nullable field in an Entity set the defaults value to null and also When generating a field in an Entity set the default value from MySQL's default

    opened by mbpcoder 0
  • Generate some useful function base on the index I created in my table

    Generate some useful function base on the index I created in my table

    In some tables, we created Indexes so that fetching data would be faster we create those indexes for getting data so it is good to generate get functions based on those indexes

    enhancement 
    opened by mbpcoder 0
  • Keep already written function and ... when generating

    Keep already written function and ... when generating

    Keep already written function and ... when generating a class for the second time Sometimes I change a table and add some new fields so this time when I run the generate command check if there was any customer function in repo, entity,... and keep them as part of the newly generated class

    enhancement 
    opened by mbpcoder 0
Releases(1.1.2)
Owner
Bakery
Bakery
Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the wtfzdotnet/php-tmdb-api library.

Laravel Package for TMDB API Wrapper A Laravel package that provides easy access to the php-tmdb/api TMDB (The Movie Database) API wrapper. This packa

PHP - The Movie Database 151 Nov 1, 2022
Update multiple Laravel Model records, each with it's own set of values, sending a single query to your database!

Laravel Mass Update Update multiple Laravel Model records, each with its own set of values, sending a single query to your database! Installation You

Jorge González 88 Dec 31, 2022
Collection of the Laravel/Eloquent Model classes that allows you to get data directly from a Magento 2 database.

Laragento LAravel MAgento Micro services Magento 2 has legacy code based on abandoned Zend Framework 1 with really ugly ORM on top of outdated Zend_DB

Egor Shitikov 87 Nov 26, 2022
Save Model is a Laravel package that allows you to save data in the database in a new way.

Save Model is a Laravel package that allows you to save data in the database in a new way. No need to worry about $guarded and $fillable properties in the model anymore. Just relax an use Save Model package.

Laratips 27 Mar 2, 2022
For using Laravel with a pre-existing MySQL Database

MySQL to Laravel This is a script to help with mapping an existing MySQL database to a new Laravel build. Place the script in the public folder of you

Chad Haney 17 Nov 29, 2022
An in-app database management UI for Laravel applications. ⚡️

:package_description This repo can be used to scaffold a Laravel package. Follow these steps to get started: Press the "Use template" button at the to

Ryan Chandler 3 Nov 13, 2021
Laravel package to normalize your data before saving into the database.

This package helps you normalize your data in order to save them into the database. The Goal is to having separate classes that handle the data normalization, and thus can be tested independently.

Nicolas Widart 11 Apr 21, 2021
Trait for Laravel testing to count/assert about database queries

counts_database_queries Trait for Laravel testing to count/assert about database queries Installing composer require ohffs/counts-database-queries-tra

null 1 Feb 23, 2022
Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.

Laravel Migrations Generator Generate Laravel Migrations from an existing database, including indexes and foreign keys! This package is cloned from ht

Kit Loong 1.4k Jan 1, 2023
LERN is a Laravel package that will record exceptions into a database and will notify you via Email, Pushover or Slack.

LERN is a Laravel package that will record exceptions into a database and will notify you via Email, Pushover or Slack.

Tyler Arbon 437 Nov 17, 2022