Skip to content

nguyenalter/Simple-Laravel-CRUD

 
 

Repository files navigation

Simple Laravel CRUD

Simple Laravel Web Application with CRUD (Create, Read, Update, Delete) functions.

Prerequisites

  • PHP: ^7.1.3
  • Composer installed
  • Created a database named laravel_crud

Installation

  • Clone this repository

    git clone https://github.com/nguyenalter/Simple-Laravel-CRUD.git
    
  • Copy or rename file .env.example to .env, and edit the file to change the attributes for database to your database configurations (host,username,password etc)

  • Open up Command Prompt (CMD) or Terminal in the project directory and run these commands:

    composer update
    php artisan key:generate
    php artisan migrate
    
  • Test Kacher-package

    I have cloned the package and changed doctrine/dbal to version ^2.10 to make it work.

    - For listing all tables in database : php artisan dbml:list
    - For Parse from DB to DBML : php artisan dbml:parse
    

Result

Schemas

  • Table users
    Schema::create('users', function (Blueprint $table) {
      $table->increments('id');
      $table->string('name');
      $table->string('email')->unique();
      $table->string('password');
      $table->rememberToken();
      $table->timestamps();
    });
  • Table password_resets
    Schema::create('password_resets', function (Blueprint $table) {
      $table->string('email')->index();
      $table->string('token')->index();
      $table->timestamp('created_at')->nullable();
    });
  • Table stocks
    Schema::create('stocks', function (Blueprint $table) {
      $table->increments('id');
      $table->string('stk_type');
      $table->string('stk_name');
      $table->string('stk_size');
      $table->integer('stk_qty');
      $table->timestamps();
    });

Output

Output seems to included migrations table too!

$ php artisan dbml:list


 0/4 [>---------------------------]   0%+------------+------------------+-------------+----------------+
| table      | columns          | foreign_key | indexes        |
+------------+------------------+-------------+----------------+
| migrations | name : id        |             | name : PRIMARY |
|            | type : integer   |             | columns : id   |
|            |                  |             | unique : yes   |
|            | name : migration |             | primary : yes  |
|            | type : string    |             |                |
|            |                  |             |                |
|            | name : batch     |             |                |
|            | type : integer   |             |                |
|            |                  |             |                |
+------------+------------------+-------------+----------------+


+-----------------+-------------------+-------------+------------------------------------+
| table           | columns           | foreign_key | indexes                            |
+-----------------+-------------------+-------------+------------------------------------+
| password_resets | name : email      |             | name : password_resets_email_index |
|                 | type : string     |             | columns : email                    |
|                 |                   |             | unique : no                        |
|                 | name : token      |             | primary : no                       |
|                 | type : string     |             |                                    |
|                 |                   |             | name : password_resets_token_index |
|                 | name : created_at |             | columns : token                    |
|                 | type : datetime   |             | unique : no                        |
|                 |                   |             | primary : no                       |
|                 |                   |             |                                    |
+-----------------+-------------------+-------------+------------------------------------+


+--------+-------------------+-------------+----------------+
| table  | columns           | foreign_key | indexes        |
+--------+-------------------+-------------+----------------+
| stocks | name : id         |             | name : PRIMARY |
|        | type : integer    |             | columns : id   |
|        |                   |             | unique : yes   |
|        | name : stk_type   |             | primary : yes  |
|        | type : string     |             |                |
|        |                   |             |                |
|        | name : stk_name   |             |                |
|        | type : string     |             |                |
|        |                   |             |                |
|        | name : stk_size   |             |                |
|        | type : string     |             |                |
|        |                   |             |                |
|        | name : stk_qty    |             |                |
|        | type : integer    |             |                |
|        |                   |             |                |
|        | name : created_at |             |                |
|        | type : datetime   |             |                |
|        |                   |             |                |
|        | name : updated_at |             |                |
|        | type : datetime   |             |                |
|        |                   |             |                |
+--------+-------------------+-------------+----------------+


+-------+-----------------------+-------------+---------------------------+
| table | columns               | foreign_key | indexes                   |
+-------+-----------------------+-------------+---------------------------+
| users | name : id             |             | name : PRIMARY            |
|       | type : integer        |             | columns : id              |
|       |                       |             | unique : yes              |
|       | name : name           |             | primary : yes             |
|       | type : string         |             |                           |
|       |                       |             | name : users_email_unique |
|       | name : email          |             | columns : email           |
|       | type : string         |             | unique : yes              |
|       |                       |             | primary : no              |
|       | name : password       |             |                           |
|       | type : string         |             |                           |
|       |                       |             |                           |
|       | name : remember_token |             |                           |
|       | type : string         |             |                           |
|       |                       |             |                           |
|       | name : created_at     |             |                           |
|       | type : datetime       |             |                           |
|       |                       |             |                           |
|       | name : updated_at     |             |                           |
|       | type : datetime       |             |                           |
|       |                       |             |                           |
+-------+-----------------------+-------------+---------------------------+


 4/4 [============================] 100%

$ php artisan dbml:parse

Table migrations {
	id integer [pk,unique,not null]
	migration string(255) [not null]
	batch integer [not null]

	indexes{
		id [pk]
	}
}
Table password_resets {
	email string(255) [not null]
	token string(255) [not null]
	created_at datetime [null]

	indexes{
		email
		token
	}
}
Table stocks {
	id integer [pk,unique,not null]
	stk_type string(255) [not null]
	stk_name string(255) [not null]
	stk_size string(255) [not null]
	stk_qty integer [not null]
	created_at datetime [null]
	updated_at datetime [null]

	indexes{
		id [pk]
	}
}
Table users {
	id integer [pk,unique,not null]
	name string(255) [not null]
	email string(255) [unique,not null]
	password string(255) [not null]
	remember_token string(100) [null]
	created_at datetime [null]
	updated_at datetime [null]

	indexes{
		id [pk]
		email [unique]
	}
}

Conclusion

  • Conflict package illuminate/support": "^7.0|^8.0: I have changed laravel/framework version to ^7.0 (the original is 5.*).
  • Must downgrade Kacher's doctrine/dbal version to ^2.10 or ^2.0 to solve this error
  • I don't know if Kacher package can support other Laravel version (worked with ^7.0)
  • The installation command should be: composer require aphisitworachorch/kacher:dev-start because Kacher package don't have a stable released version

Credits

About

Simple Laravel Web Application with CRUD

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 72.1%
  • Blade 26.2%
  • Other 1.7%