Skip to content

Commit 519c6d5

Browse files
author
Emre Akay
committed
bismillah
1 parent fa66183 commit 519c6d5

File tree

2 files changed

+71
-50
lines changed

2 files changed

+71
-50
lines changed

README.md

Lines changed: 64 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,103 @@
1-
# Laravel Models on the FLY !
21

3-
[![Latest Version on Packagist](https://img.shields.io/packagist/v/aurora-web-software-team/flymodel.svg?style=flat-square)](https://packagist.org/packages/aurora-web-software-team/flymodel)
4-
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/aurora-web-software-team/flymodel/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/aurora-web-software-team/flymodel/actions?query=workflow%3Arun-tests+branch%3Amain)
5-
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/aurora-web-software-team/flymodel/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/aurora-web-software-team/flymodel/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
6-
[![Total Downloads](https://img.shields.io/packagist/dt/aurora-web-software-team/flymodel.svg?style=flat-square)](https://packagist.org/packages/aurora-web-software-team/flymodel)
2+
# FlyModel: Dynamic Laravel Models on the Fly
73

8-
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
4+
FlyModel is a Laravel package that empowers you to create and manage models dynamically, **on the fly !**.
95

10-
## Support us
6+
It define flexible and customizable models and model fields **without needing to change** the database schema.
117

12-
[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/FlyModel.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/FlyModel)
8+
This package streamlines your workflow by eliminating the need to define models explicitly in your codebase. Instead, you can generate and interact with models as needed, based on a unique "deck" identifier.
139

14-
We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
10+
The package uses **FlexyField** Package as Dynamic Field Engine.
1511

16-
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
12+
For More Info Visit: https://github.com/AuroraWebSoftware/FlexyField
1713

18-
## Installation
14+
## 🚀 Features
1915

20-
You can install the package via composer:
16+
- **Dynamic Model Creation**: Instantiate models with a specified "deck" identifier without pre-defining them.
17+
- **Dynamic Fields** : Define flexible and customizable fields on models **without needing to change** the database schema.
18+
- **Automatic Scoping**: Models are automatically scoped according to the deck, ensuring data isolation.
19+
- **Seamless Integration**: Works effortlessly with Laravel’s Eloquent ORM.
20+
21+
## 📦 Installation
22+
23+
To get started with FlyModel, follow these steps:
24+
25+
### Install the Package
26+
27+
Add FlyModel to your project using Composer:
2128

2229
```bash
23-
composer require aurora-web-software-team/flymodel
30+
composer require aurorawebsoftware/flymodel
2431
```
2532

26-
You can publish and run the migrations with:
33+
### Run the Migration
34+
35+
Create the necessary database table for storing fly models:
2736

2837
```bash
29-
php artisan vendor:publish --tag="flymodel-migrations"
3038
php artisan migrate
3139
```
3240

33-
You can publish the config file with:
3441

35-
```bash
36-
php artisan vendor:publish --tag="flymodel-config"
37-
```
42+
## 📘 Usage
3843

39-
This is the contents of the published config file:
44+
### Creating and Using Fly Models
4045

41-
```php
42-
return [
43-
];
44-
```
46+
With FlyModel, you can dynamically create models and perform various operations. Here’s how:
4547

46-
Optionally, you can publish the views using
48+
Instantiate a Model with a Deck
4749

48-
```bash
49-
php artisan vendor:publish --tag="flymodel-views"
50+
```php
51+
$building = FlyModel::of('building');
5052
```
5153

52-
## Usage
54+
Save the Model if not saved or created before
5355

5456
```php
55-
$flyModel = new AuroraWebSoftware\FlyModel();
56-
echo $flyModel->echoPhrase('Hello, AuroraWebSoftware!');
57+
$building->save();
5758
```
5859

59-
## Testing
60-
61-
```bash
62-
composer test
60+
Perform Field Operations
61+
```php
62+
$building->flexy->name = 'Headquarter Building'
63+
$building->flexy->address = 'Ali Pasha Ave. number 10';
64+
$building->flexy->city = 'İstanbul';
65+
$building->flexy->floor = 7;
66+
$building->flexy->area = 313;
67+
$building->flexy->active = true;
68+
69+
$building->save();
6370
```
6471

65-
## Changelog
6672

67-
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
73+
Perform Eloquent Operations
6874

69-
## Contributing
75+
```php
76+
$buildings = FlyModel::of('building')->all();
77+
78+
$istanbulBuildings = FlyModel::of('building')
79+
->where('flexy_city', 'İstanbul')
80+
->get();
81+
82+
$largeBuildings = FlyModel::of('building')
83+
->where('flexy_area', '>' 500)
84+
->orderBy('flexy_area')
85+
->get();
86+
87+
$highBuildingsInIstanbul = FlyModel::of('building')
88+
->where('flexy_floor', '>' 10)
89+
->where('flexy_city', 'İstanbul')
90+
->get();
91+
```
7092

71-
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
7293

73-
## Security Vulnerabilities
94+
## 🧪 Testing
7495

75-
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
96+
FlyModel integrates with Laravel’s testing environment. Here’s an example of how to write tests for it:
7697

77-
## Credits
7898

79-
- [Aurora Web Software Team](https://github.com/Aurora Web Software Team)
80-
- [All Contributors](../../contributors)
8199

82-
## License
100+
## 💬 Contributing
83101

84-
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
102+
We welcome contributions to improve FlyModel!
103+
##

tests/PackageTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313

1414
it('can test', function () {
1515

16-
FlyModel::of('deck1')->save();
17-
$deck1 = FlyModel::of('deck1')->find(1);
16+
$model = FlyModel::of('deck1');
17+
$model->save();
1818

19-
$deck1->flexy->a = 'a';
20-
$deck1->save();
2119

22-
expect(FlyModel::of('deck1')->find($deck1->id)->flexy->a)
20+
21+
$model->flexy->a = 'a';
22+
$model->save();
23+
24+
expect(FlyModel::of('deck1')->find($model->id)->flexy->a)
2325
->toBe('a');
2426

2527
});

0 commit comments

Comments
 (0)