当前位置:网站首页>Laravel 5.8 Notes
Laravel 5.8 Notes
2022-08-08 18:17:00 【owenzhang24】
Laravel 5.8 Notes
Template engine rendering
return Admin::content(function (Content $content) use ($lists) { $content->description('text management'); $content->breadcrumb( ['text' => 'textManagement', 'left-menu-active' => 'text management'] ); $content->body(view('shuabao-backend::text.index', compact('lists'))); });{{ $description }}
Data Migration
Migrations are like database version control, allowing teams to easily and easily edit and share an application's database table structure. Migrations are often used in conjunction with Laravel's database structure generator, allowing you to easily build database structures.If you've ever tried to get a colleague to manually add fields to your database structure, database migrations can save you from having to do that.
Generate Migration
php artisan make
:migration create_users_table
The new migration is located in the database/migrations
directory.Each migration filename includes a timestamp to allow Laravel to confirm the order of migrations.
--table
and --create
options can be used to specify the name of the data table, or whether a new data table will be created when the migration is executed.These options need to be filled in the specified data table when pre-generating the migration file:
php artisan make
:migration create_users_table
--create
=users
php artisan make
:migration add_votes_to_users_table
--table
=users
Run Migration
php artisan migrate
Force migration in production
Some migration operations are destructive, meaning that data loss may result.To prevent someone from running these commands in production, the system will check with you before these commands are run.If you want to force the command to run ignoring the system prompt, you can use the --force
tag:
php artisan migrate
--force
Rollback migration
To roll back the last migration, use the rollback
command.This command will roll back the last "migrate" operation, which may contain multiple migration files:
php artisan migrate
:rollback
You can limit the number of rollback migrations by adding the step
parameter after the rollback
command.For example, the following command will roll back the last five migrations:
php artisan migrate
:rollback
--step
=5
migrate:reset
command rolls back all migrations in the application:
php artisan migrate
:reset
Use a single command to perform a rollback or migration
Themigrate:refresh
command not only rolls back all migrations of the database but also runs the migrate
command next.This command can efficiently rebuild the entire database:
php artisan migrate
:refresh
// Refresh the database and run all database seeds...
php artisan migrate
:refresh
--seed
Use the refresh
command and supply the step
parameter to roll back and execute the last specified number of migrations.For example, the following command will roll back and re-execute the last five migrations:
php artisan migrate
:refresh
--step
=5
Delete All Tables & Migration
php artisan migrate
:fresh
php artisan migrate
:fresh
--seed
Adjust to another route
return route('FilePull', $arr);Route::get('file', \[ 'as' =\> 'FilePull', 'alias' =\> 'Get file', 'uses' =\> '[email protected]' \]);
Deletions and soft deletes
_Cases::find($id)->delete();_ Cases::destroy($id); _//__soft delete recovery// Cases::find($id)->restore();_
Delete the model permanently
//
Force deletion of a single model instance...
$flight->forceDelete();
//
Force delete all associated models...
$flight->history()->forceDelete();
Give parameter default value
$request->input('company_name','sdfsaf');Buy me a cup of coffee :)
边栏推荐
猜你喜欢
随机推荐
差分信号简述
【FPGA教程案例46】图像案例6——基于FPGA的图像高斯滤波verilog实现,通过MATLAB进行辅助验证
阿里巴巴云原生大数据运维平台 SREWorks 正式开源
高维前缀和和子集dp(状压dp的一种)
Task-Driven Super Resolution: Object Detection in Low-resolution Images
uva1432
携手华为打造鲲鹏产业生态 | 麒麟信安亮相鲲鹏开发者创享日·长沙站
CF533B(树形dp+转移技巧)
diff 命令
智文最终版本
常用字符的编码
数字货币永续合约交易所开发开发功能以及代码呈现
Laravel 5.8笔记
poj1363 Rails(栈模拟)
如何让您的wiki内容更高级?
21天学习第五天--数组
全栈开发可能需要的环境及工具
搭建企业级数据治理体系指南
倒置字符串
canvas城市灯火夜景动画js特效