Laravel框架(房源属性)

一.房源属性表设计

房源属性是对一个房源的信息的补充和描述,在日后的展示和数据调用检索中都有着重要的条件依据。如下图所示,框选区域为房源的属性
在这里插入图片描述

1.创建房源属性和对应的迁移文件

php artisan make:model Models/Fangattr -m

2.迁移文件代码

Schema::create('fangattrs', function (Blueprint $table) {
    // 主键
    $table->bigIncrements('id');
	$table->unsignedInteger('pid')->default(0)->comment('上级ID');
	$table->string('field_name',50)->default('')->comment('字段名');
    $table->string('name',50)->default('')->comment('属性名称');
    $table->string('icon',200)->default('')->comment('图标');
    $table->timestamps();
    // 软删除
    $table->softDeletes();
});

3.执行迁移生成对应的数据表

php artisan migrate

二.房源属性列表

1.创建对应资源控制器和资源路由

php artisan make:controller Admin/FangAttrController -r -m Models/Fangattr

Route::resource('fangattr','FangAttrController ',['as'=>'admin']);

资源路由==普通路由

//文件上传
Route::post('fangattr/upfile','FangAttrController@upfile')->name('admin.fangattr.upfile');
//展示页面
Route::get('fangattr/index','FangAttrController@index')->name('admin.fangattr.index');
//添加页面
Route::get('fangattr/create','FangAttrController@create')->name('admin.fangattr.create');
//添加
Route::post('fangattr/store','FangAttrController@store')->name('admin.fangattr.store');
//删除
Route::get('fangattr/del/{id}','FangAttrController@destroy')->name('admin.fangattr.destroy');
//软删除还原
Route::get('fangattr/restore/{id}','FangAttrController@restore')->name('admin.fangattr.restore');
//修改页面
Route::get('fangattr/edit/{id}','FangAttrController@edit')->name('admin.fangattr.edit');
//修改
Route::put('fangattr/edit/{id}','FangAttrController@update')->name('admin.fangattr.update');

2.准备页面

@extends('admin.common.main_app')

@section('css')
@endsection

@section('cnt')

<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
	<span class="c-gray en">&gt;</span> 房源属性管理
	<span class="c-gray en">&gt;</span> 房源属性列表
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
		<i class="Hui-iconfont">&#xe68f;</i>
		</a>
</nav>
<div class="page-container">
    <form method="get" class="text-c"> 输入你想要搜索的权限名称:
        <input type="text" name="username"  class="input-text" style="width:120px;">
        <button type="submit" class="btn btn-success radius" id="" name="">
            <i class="Hui-iconfont">&#xe665;</i> 搜节点
        </button>
    </form>

    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            <a href="{
  {route('admin.fangattr.create')}}"  class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加房源属性</a>
        </span>
        <span class="r">共有数据:<strong>88</strong> 条</span>
    </div>

    @include('admin.common.validate')
    @include('admin.common.msg')
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th width="80">ID</th>
                <th width="80">房源属性名称</th>
                <th width="80">图标</th>
                <th width="80">字段名称</th>
               
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值