Category: Laravel 6
-
Post Views: 16 1. In Laravel 6, execute the UpdateOrCreate method to update the existing model or create a new model if it does not exist. The last generated sql is as follows, the field checksum is missing. as shown in Figure 1 2. The code is implemented as follows: 3. Print the variable $extra, and determine that the field…
-
Post Views: 16 1. There was an implementation before, which is to judge a specific record, whether it meets a certain complex nesting condition, and the code is implemented as follows 2. Now you need to query all records that meet this complex nesting condition, refer to:https://learnku.com/docs/laravel/6.x/queries/5171#2f5914, the code is implemented as follows 3. The final generated SQL is in…
-
Post Views: 13 1. Now there is a string with the following contents 2. It is expected to batch replace the default in the string to basic 3. Refer to the str::replaceArray function to replace the given value in the string using the array order 4. Since there is only one element in the array $replace, only one default is…
-
Post Views: 17 1. In Laravel 6, in the terminal, you can confirm that the queue has been executed. as shown in Figure 1 2. However, in Laravel Telescope, the status of the queuing job still shows that it is not finished. as shown in Figure 2 3. It is suspected that after updating Telescope, there is no reconfiguration and…
-
Post Views: 20 1. When the file module.json is deleted under modules/blog, a new migration file is generated: nwidart\modules\exceptions\moduleNotFoundException : module[Blog]does not exist!. as shown in Figure 1 2. Use the make:migration artisan command to create a migration, and use the –path option to customize the personal storage path that generates the migration file. as shown in Figure 2 3.…
-
Post Views: 62 1. Generate a new module: blog. 2. By default, the module class will not load automatically. You can load your modules automatically using PSR-4. Edit composer.json. as shown in Figure 1 3. Tip: Don’t forget to run composer dump-autoload. as shown in Figure 2 4. Generate a given console command for the specified module. 5. Edit CreatePostCommand.php,…
-
Post Views: 14 1. There are 2 fields in the table: original_theme_id, theme_id, the value of the field original_theme_id is derived from the theme_id of another record in the table. as shown in Figure 1 2. Set a one-to-one reverse association in the model. The code is implemented as follows 3. Get the code implementation of the associated attribute, the…
-
Post Views: 17 1. In MySQL 5.7, the data in the json type field is an array, and its value is:[365]. as shown in Figure 1 2. Reference: Query the constructor – where statement – json where statement:https://learnku.com/docs/laravel/6.x/queries/5171#35d9d9. JSON arrays can be queried using WhereJsonContains. as shown in Figure 2 3. The code is implemented as follows 4. Print the…
-
Post Views: 18 1. Doctrine\dbal\exception : unknown database type enum requested, doctrine\dbal\platforms\mysql57platform may not support it.. as shown in Figure 1 2. View the migration file, enum does not exist in the updated field type 3. The reason for the final determination may be that in the table involved in this migration file, the type of other fields is enum.…