当前位置:网站首页>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 :)
边栏推荐
- 记录贴:pytorch学习Part3
- what‘s the meaning of xenial
- torchvision.transforms
- Nioke 2022 Summer Multi-School 6 B Eezie and Pie (Difference on the tree + multiplication to find the kth ancestor board)
- 2021年9月电子学会图形化一级编程题解析含答案:无奈的Jaime
- echart 股票数据分析 开发备忘录
- vlan同步—VTP通告
- /目录 、/home目录 、~目录的区别
- 面经刺客 | 关于——字节飞书基础架构产品 日常实习面经
- CS231n: 11 Generative Models
猜你喜欢
随机推荐
CF1716D(“按顺序“的完全背包)
DHCP服务初探
SUSECON 北京议程上新丨8月16日相聚望京凯悦
SSH协议抓包-工具Wireshark
行政区划代码(道路要素)
请教一个oracle - cdc问题。 设置为 StartupOptions.latest()
2021年9月电子学会图形化二级编程题解析含答案:帮小企鹅躲避暴风雪
Codeforces Round #699 (Div. 2)
无需精子卵子子宫体外培育胚胎,Cell论文作者这番话让网友们炸了
Why do you need to cross compiler
TensorFlow学习记录(七):生成对抗网络
数据压缩和归档(三)、tarfile
微信小程序云开发 | 插件的微信小程序云开发
Nioke 2022 Summer Multi-School 6 B Eezie and Pie (Difference on the tree + multiplication to find the kth ancestor board)
干货技巧|如何用3DsMax制作笔记本电脑
ccdV01_20220808
21天学习第三天--常用运算符
熬夜拜读349页阿里面试通关手册,成功闯入字节
【目标检测】小脚本:根据xml批量复制jpg图片
Prometheus+Grafana监控系统