Skip to content

Commit 01f7af8

Browse files
authored
Update readme.md
1 parent f0b6637 commit 01f7af8

File tree

1 file changed

+99
-7
lines changed

1 file changed

+99
-7
lines changed

readme.md

Lines changed: 99 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,114 @@
1-
# LaravelDynamicModel
1+
# Laravel Dynamic Model
22

3-
[![Latest Version on Packagist][ico-version]][link-packagist]
4-
[![Total Downloads][ico-downloads]][link-downloads]
5-
[![Build Status][ico-travis]][link-travis]
6-
[![StyleCI][ico-styleci]][link-styleci]
3+
<p align="left">
4+
<!--<a href="https://packagist.org/packages/sairahcaz/laravel-dynamic-model"><img src="https://img.shields.io/packagist/dt/sairahcaz/laravel-dynamic-model" alt="Total Downloads"></a>-->
5+
<a href="https://packagist.org/packages/sairahcaz/laravel-dynamic-model"><img src="https://img.shields.io/packagist/v/sairahcaz/laravel-dynamic-model" alt="Latest Stable Version"></a>
6+
<a href="https://packagist.org/packages/sairahcaz/laravel-dynamic-model"><img src="https://img.shields.io/packagist/l/sairahcaz/laravel-dynamic-model" alt="License"></a>
7+
</p>
78

8-
This is where your description should go. Take a look at [contributing.md](contributing.md) to see a to do list.
9+
## Introduction
10+
11+
Laravel Dynamic Model provides you with a model which can handle multiple database tables.
12+
*Warning*: this is only a good approach if you really know what your doing and you have no other option!
913

1014
## Installation
1115

12-
Via Composer
16+
Dependencies
17+
This package depends on Doctrine/DBAL, so make sure you have it or install it.
18+
19+
``` bash
20+
$ composer require doctrine/dbal
21+
```
22+
23+
Package
1324

1425
``` bash
1526
$ composer require sairahcaz/laravel-dynamic-model
27+
$ php artisan vendor:publish --provider="Sairahcaz\LaravelDynamicModel\DynamicModelServiceProvider" --tag="config"
1628
```
1729

30+
1831
## Usage
1932

33+
### Lets create a dummy table:
34+
35+
``` bash
36+
$ php artisan make:migration create_foo_table
37+
```
38+
39+
``` php
40+
Schema::create('foo', function (Blueprint $table) {
41+
$table->id();
42+
$table->string('col1');
43+
$table->integer('col2');
44+
$table->timestamps();
45+
});
46+
```
47+
48+
### Lets use our Dynamic Model:
49+
50+
51+
``` php
52+
$foo = App::make(DynamicModel::class, ['table_name' => 'foo']);
53+
54+
$foo->create([
55+
'col1' => 'asdf',
56+
'col2' => 123
57+
]);
58+
59+
dd($foo->first());
60+
```
61+
62+
Which gives us:
63+
64+
```
65+
^ Sairahcaz\LaravelDynamicModel\DynamicModel {#328 ▼
66+
#connection: "mysql"
67+
#table: "foo"
68+
#primaryKey: "id"
69+
#keyType: "integer"
70+
+incrementing: true
71+
#with: []
72+
#withCount: []
73+
+preventsLazyLoading: false
74+
#perPage: 15
75+
+exists: true
76+
+wasRecentlyCreated: false
77+
#escapeWhenCastingToString: false
78+
#attributes: array:5 [▼
79+
"id" => 1
80+
"col1" => "asdf"
81+
"col2" => 123
82+
"created_at" => "2022-09-22 15:34:22"
83+
"updated_at" => "2022-09-22 15:34:22"
84+
]
85+
#original: array:5 [▼
86+
"id" => 1
87+
"col1" => "asdf"
88+
"col2" => 123
89+
"created_at" => "2022-09-22 15:34:22"
90+
"updated_at" => "2022-09-22 15:34:22"
91+
]
92+
#changes: []
93+
#casts: []
94+
#classCastCache: []
95+
#attributeCastCache: []
96+
#dates: []
97+
#dateFormat: null
98+
#appends: []
99+
#dispatchesEvents: []
100+
#observables: []
101+
#relations: []
102+
#touches: []
103+
+timestamps: true
104+
#hidden: []
105+
#visible: []
106+
#fillable: []
107+
#guarded: []
108+
#routeKeyName: "id"
109+
}
110+
```
111+
20112
## Change log
21113

22114
Please see the [changelog](changelog.md) for more information on what has changed recently.

0 commit comments

Comments
 (0)