一個類繼承了基類,在一個訪問中修改了基類的數(shù)據(jù),另外的一個子類直接讀取了上個基類的賦值```php
class UserService extends BaseService
{
public function index()
{
$this->view = 'system/user/index';
$current_page = request()->input('page', 1);
$user = User::with('roles')->paginate(config('user.page_size'), '*', 'page', $current_page);
$paginator = new Page($user->total(), config('user.page_size'), $current_page);
$this->data['users'] = $user;
$this->data['paginator'] = $paginator;
return $this->view();
}
public function create()
{
$this->view = 'system/user/create';
$this->data['roles'] = Role::get();
return $this->view();
}
}
如index賦值data users,paginator,create賦值roles,在第三個請求中會把這些數(shù)據(jù)全帶出來