私が望むのは月のフィールドです。ユーザーが月を自動設定した場合、で作成した月は月に作成され、データベースにアップロードされます。バックパックlaravelで有効期限を自動的に計算する方法は?
PS - 申し訳ありませんが私はlaravel
で新しい午前の編集を参照してください。
私の店の方法は、あなたがヶ月を意味すると仮定すると
<?php
namespace App\Http\Controllers\Admin;
use Backpack\CRUD\app\Http\Controllers\CrudController;
// VALIDATION: change the requests to match your own file names if you need
form validation
use App\Http\Requests\ClientsRequest as StoreRequest;
use App\Http\Requests\ClientsRequest as UpdateRequest;
use Carbon\Carbon;
class ClientsCrudController extends CrudController
{
public function setup()
{
$this->crud->setModel('App\Models\Clients');
$this->crud->setRoute(config('backpack.base.route_prefix') . '/clients');
$this->crud->setEntityNameStrings('clients', 'clients');
$this->crud->setFromDb();
}
public function store(StoreRequest $request)
{
// your additional operations before save here
$start_day = Carbon::parse($request->created_at);
$expiry_day = $start_day->addMonths($request->month);
$request->input($expiry_day);
$redirect_location = parent::storeCrud($request);
// your additional operations after save here
// use $this->data['entry'] or $this->crud->entry
return $redirect_location;
}
public function update(UpdateRequest $request)
{
// your additional operations before save here
$redirect_location = parent::updateCrud($request);
// your additional operations after save here
// use $this->data['entry'] or $this->crud->entry
return $redirect_location;
}
}
まさにあなたは月とのcreated_atフィールドで計算したいですか?例を挙げてください。 – Jerodev
実際には、私のテーブルには、名前がcreated_atであり、expire_atである他のカラムがあります...新しいユーザ登録バックパックがcreate_atカラムを自動的に埋めるように、ユーザに依存するexpire_atカラムを満たす必要があります月 –