12 changed files with 74 additions and 79 deletions
-
2app/Admin/Controllers/LanzuCsInfoController.php
-
13app/Admin/Controllers/LanzuCsWithdrawController.php
-
39app/Admin/Controllers/LanzuFinancialRecord.php
-
1app/Admin/routes.php
-
1app/Models/BaseModel.php
-
84app/Models/FinancialRecord.php
-
3app/Models/FinancialRecord0.php
-
2app/Models/FinancialRecord1.php
-
2app/Models/FinancialRecord2.php
-
2app/Models/FinancialRecord3.php
-
2app/Models/FinancialRecord4.php
-
2app/Models/LanzuCsInfo.php
@ -0,0 +1,39 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\Admin\Controllers; |
|||
|
|||
|
|||
use App\Models\AdminUsers; |
|||
use App\Models\FinancialRecord0; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Grid; |
|||
|
|||
class LanzuFinancialRecord extends AdminController |
|||
{ |
|||
protected function grid() |
|||
{ |
|||
return Grid::make(new FinancialRecord0(),function (Grid $grid){ |
|||
$grid->id; |
|||
$grid->user_id('用户'); |
|||
$grid->money('金额'); |
|||
$grid->desc('说明'); |
|||
$grid->created_at('创建时间'); |
|||
$grid->filter(function (Grid\Filter $filter){ |
|||
$filter->equal('id'); |
|||
}); |
|||
$grid->disableViewButton(); |
|||
$grid->disableCreateButton(); |
|||
$grid->disableEditButton(); |
|||
$grid->disableDeleteButton(); |
|||
}); |
|||
} |
|||
|
|||
protected function form() |
|||
{ |
|||
return Form::make(new FinancialRecord0(),function (Form $form){ |
|||
$form->datetime('created_at'); |
|||
}); |
|||
} |
|||
} |
|||
@ -1,85 +1,25 @@ |
|||
<?php |
|||
|
|||
namespace App\Models; |
|||
|
|||
use App\Models\BaseModel; |
|||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
use DB; |
|||
|
|||
// class FinancialRecord0 extends BaseModel
|
|||
// {
|
|||
// protected $table = 'lanzu_financial_record_0';
|
|||
// }
|
|||
|
|||
// class FinancialRecord1 extends BaseModel
|
|||
// {
|
|||
// protected $table = 'lanzu_financial_record_1';
|
|||
// }
|
|||
|
|||
// class FinancialRecord2 extends BaseModel
|
|||
// {
|
|||
// protected $table = 'lanzu_financial_record_2';
|
|||
// }
|
|||
|
|||
// class FinancialRecord3 extends BaseModel
|
|||
// {
|
|||
// protected $table = 'lanzu_financial_record_3';
|
|||
// }
|
|||
|
|||
// class FinancialRecord4 extends BaseModel
|
|||
// {
|
|||
// protected $table = 'lanzu_financial_record_4';
|
|||
// }
|
|||
|
|||
class FinancialRecord extends Model |
|||
{ |
|||
|
|||
public function __construct($table = null) |
|||
{ |
|||
|
|||
$index = $user_id % 5; |
|||
$table_name = 'lanzu_financial_record_0'; |
|||
switch ($index) { |
|||
case 0: |
|||
case 1: |
|||
case 2: |
|||
case 3: |
|||
case 4: |
|||
$table_name = 'lanzu_financial_record_' . $index; |
|||
$model_name = 'App\\Models\\'.'FinancialRecord1'; |
|||
//$buider = DB::table($table_name);
|
|||
$model = new BaseModel; |
|||
$model->setTable($table_name); |
|||
$buider = $model; |
|||
//$buider = $buider::where('id',1);
|
|||
// $buider = $buider::where('id',1);
|
|||
default: |
|||
# code...
|
|||
break; |
|||
} |
|||
|
|||
//if(empty($table)) $table = 'lanzu_financial_record_0';
|
|||
$this->setTable($table_name); |
|||
parent::__construct([]); |
|||
} |
|||
|
|||
use HasDateTimeFormatter; |
|||
protected $dateFormat = 'U'; |
|||
|
|||
/** |
|||
* 根据用户id创建不同模型 |
|||
* @param $user_id |
|||
* @return string |
|||
*/ |
|||
public static function getFinancialRecordModel($user_id){ |
|||
$buider = null; |
|||
$index = $user_id % 5; |
|||
|
|||
switch ($index) { |
|||
case 0: |
|||
case 1: |
|||
case 2: |
|||
case 3: |
|||
case 4: |
|||
dump($index); |
|||
$model_name = 'App\\Models\\'.'FinancialRecord'.$index; |
|||
$buider = $model_name; |
|||
default: |
|||
# code...
|
|||
break; |
|||
} |
|||
$model_name = 'App\\Models\\'.'FinancialRecord'.$index; |
|||
$buider = new $model_name(); |
|||
return $buider; |
|||
} |
|||
|
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue