Download the PHP package crocodicstudio/cbmodel without Composer
On this page you can find all versions of the php package crocodicstudio/cbmodel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download crocodicstudio/cbmodel
More information about crocodicstudio/cbmodel
Files in crocodicstudio/cbmodel
Package cbmodel
Short Description Boost your laravel database relation with model enhancement
License MIT
Informations about the package cbmodel
CB Laravel Model Repository
An alternative about laravel eloquent
This Package Is Deprecated
Please use https://github.com/crocodic-studio/laravel-model
Requirement
Laravel 5. | 6. | 7.*
Install Command
composer require crocodicstudio/cbmodel=^2.0
1. Create a model
Create a model from a table
php artisan create:model foo_bar_table
Create model for all tables
php artisan create:model
Create a model with other connection
php artisan create:model foo_bar_table --connection=con2
I assume that you have a table with the structure like bellow:
It will auto create a new file at with the following file structure :
2. Using CB Model class on your Controller
Insert at top of your controller class name.
3. Using CB Model class that has a relation
I assume you have a table for book relation like bellow :
and your book structure to be like bellow:
Now you have to create a model for table, you can following previous steps.
I assume that you have create a model, so make sure that now we have two files in the
Open the Books model , and add this bellow method
Then open the FooController
As you can see now we can get the category name by using without any SQL Query or even Database Builder syntax. Also you can recursively go down to your relation with NO LIMIT.
4. How to Casting DB Builder Collection output to CB Model Class?
You can easily cast your simple database builder collection to cb model class.
5. How to insert the data with CB Model
You can easily insert the data with method like bellow:
Then if you want to get the last insert id you can do like bellow:
5. How to update the data with CB Model
You can easily update the data, just find it for first :
5. How to delete the data?
You can easily delete the data, just find it for first :
or
Model Method Available
A One-To-Many Relationship
A One-To-One Relationship
Other Useful
All versions of cbmodel with dependencies
doctrine/dbal Version ^2.10
illuminate/support Version ^5.7|^6.0|^7.0
illuminate/console Version ^5.7|^6.0|^7.0