|
1 | | -# Laravel Models on the FLY ! |
2 | 1 |
|
3 | | -[](https://packagist.org/packages/aurora-web-software-team/flymodel) |
4 | | -[](https://github.com/aurora-web-software-team/flymodel/actions?query=workflow%3Arun-tests+branch%3Amain) |
5 | | -[](https://github.com/aurora-web-software-team/flymodel/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain) |
6 | | -[](https://packagist.org/packages/aurora-web-software-team/flymodel) |
| 2 | +# FlyModel: Dynamic Laravel Models on the Fly |
7 | 3 |
|
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 !**. |
9 | 5 |
|
10 | | -## Support us |
| 6 | +It define flexible and customizable models and model fields **without needing to change** the database schema. |
11 | 7 |
|
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. |
13 | 9 |
|
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. |
15 | 11 |
|
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 |
17 | 13 |
|
18 | | -## Installation |
| 14 | +## 🚀 Features |
19 | 15 |
|
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: |
21 | 28 |
|
22 | 29 | ```bash |
23 | | -composer require aurora-web-software-team/flymodel |
| 30 | +composer require aurorawebsoftware/flymodel |
24 | 31 | ``` |
25 | 32 |
|
26 | | -You can publish and run the migrations with: |
| 33 | +### Run the Migration |
| 34 | + |
| 35 | +Create the necessary database table for storing fly models: |
27 | 36 |
|
28 | 37 | ```bash |
29 | | -php artisan vendor:publish --tag="flymodel-migrations" |
30 | 38 | php artisan migrate |
31 | 39 | ``` |
32 | 40 |
|
33 | | -You can publish the config file with: |
34 | 41 |
|
35 | | -```bash |
36 | | -php artisan vendor:publish --tag="flymodel-config" |
37 | | -``` |
| 42 | +## 📘 Usage |
38 | 43 |
|
39 | | -This is the contents of the published config file: |
| 44 | +### Creating and Using Fly Models |
40 | 45 |
|
41 | | -```php |
42 | | -return [ |
43 | | -]; |
44 | | -``` |
| 46 | +With FlyModel, you can dynamically create models and perform various operations. Here’s how: |
45 | 47 |
|
46 | | -Optionally, you can publish the views using |
| 48 | +Instantiate a Model with a Deck |
47 | 49 |
|
48 | | -```bash |
49 | | -php artisan vendor:publish --tag="flymodel-views" |
| 50 | +```php |
| 51 | +$building = FlyModel::of('building'); |
50 | 52 | ``` |
51 | 53 |
|
52 | | -## Usage |
| 54 | +Save the Model if not saved or created before |
53 | 55 |
|
54 | 56 | ```php |
55 | | -$flyModel = new AuroraWebSoftware\FlyModel(); |
56 | | -echo $flyModel->echoPhrase('Hello, AuroraWebSoftware!'); |
| 57 | +$building->save(); |
57 | 58 | ``` |
58 | 59 |
|
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(); |
63 | 70 | ``` |
64 | 71 |
|
65 | | -## Changelog |
66 | 72 |
|
67 | | -Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. |
| 73 | +Perform Eloquent Operations |
68 | 74 |
|
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 | +``` |
70 | 92 |
|
71 | | -Please see [CONTRIBUTING](CONTRIBUTING.md) for details. |
72 | 93 |
|
73 | | -## Security Vulnerabilities |
| 94 | +## 🧪 Testing |
74 | 95 |
|
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: |
76 | 97 |
|
77 | | -## Credits |
78 | 98 |
|
79 | | -- [Aurora Web Software Team](https://github.com/Aurora Web Software Team) |
80 | | -- [All Contributors](../../contributors) |
81 | 99 |
|
82 | | -## License |
| 100 | +## 💬 Contributing |
83 | 101 |
|
84 | | -The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
| 102 | +We welcome contributions to improve FlyModel! |
| 103 | +## |
0 commit comments