Create a CRUDs for all your database tables in seconds using Laravel and Laravel-Code-Generator

preview_player
Показать описание
In this screencast we go through multiple command offered by Laravel-Code-Generator package. We created a very simple "Music Library" app using database-first approach using Laravel 5.5 and the awesome Laravel-Code-Generator v2.2.2!

If you like this screencast please give me a thumbs up, and share it with the community to increase awareness.

### Steps Used during the screencast
In this tutorial, I am going to assume that you watched the previous screencast, and already have the schema created. But if you did not, you can use the SQL script below to generate the tables.

To get started, I used the following command to create the first resource-file for my existing "singers" table
php artisan resource-file:from-database Singer

php artisan create:resources Singer

The next command allowed us to perform both steps listed above using one command
php artisan create:resources Singer --table-exists --force

php artisan resource-file:from-database SongCategory
php artisan resource-file:from-database Song

php artisan create:mapped-resources

Here is the SQL script needed to create the databases tables.

CREATE TABLE `singers` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`gender` enum('male','female') COLLATE utf8mb4_unicode_ci NOT NULL,
`music_type` enum('country','pop','rock','jazz','rap') COLLATE utf8mb4_unicode_ci NOT NULL,
`is_retired` tinyint(1) NOT NULL,
`notes` varchar(1000) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `song_categories` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `songs` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`album` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`singer_id` int(10) unsigned NOT NULL,
`release_year` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`song_category_id` int(10) unsigned NOT NULL,
`file` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `songs_singer_id_index` (`singer_id`),
KEY `songs_song_category_id_index` (`song_category_id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
Рекомендации по теме
Комментарии
Автор

I got to say, this package is brilliant!! I can't thank the author enough for creating and sharing it.

freemusic
Автор

This package is Art! Thanks a lot for sharing.

igorkuna
Автор

Awesome Library ! Good Job Tks so much !!!

atbui
Автор

Trying to reach documentation at CrestApps.com, but it seems to be down?

hopewise
Автор

Please help.
i install with:
composer require --dev
php artisan vendor:publish --tag=default
but whe i run
php artisan resource-file:from-database Cadastro
return:
There are no commands defined in the "resource-file" namespace.
Can u help me?

JardelBerti
Автор

Hello, Mike. I have a small problem. I already had existing database and I am trying to make resource file using php artisan resource-file:from-database [table's name]. but I keep getting error like this:
Exception : The table [table's name]s was not found in the [db's name] database.
can you help me, please
thanks

ervanrhermawan
Автор

i have this error ...syntax error, unexpected '\' (T_NS_SEPARATOR), expecting identifier (T_STRING) or '{'



use Illuminate\Http\Request;
use
use
use Exception;





?

nelstu
Автор

Hi Mike, Thank you very much for this generator. it's fantastic. I really love it :).
When working with laravel recommendation as naming tables columns with snake-case, and using lower case "id" as primary key the generator works fine.
But I tried this generator with a database with tables having Upper case ID, not auto-inctrement, not int but string insteed and all fields names are upper case. and I have problems when reversing it.
I don't know how to explain to you. If you have skype we can talk may be. Thanks (and sorry for my english :) )

progsam
Автор

hi,
when i tape the first command : php artisan resource-file:from-database Singer
i get this error : syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ']'

Can you help me please
Thanks

yassinek
join shbcf.ru