123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace App\Imports;
- use App\Http\Models\Tenant;
- use Illuminate\Validation\Rule;
- use Maatwebsite\Excel\Concerns\ToArray;
- use Maatwebsite\Excel\Concerns\ToModel;
- use Maatwebsite\Excel\Concerns\WithValidation;
- use Maatwebsite\Excel\Concerns\WithMappedCells;
- use Maatwebsite\Excel\Concerns\WithHeadings;
- use Maatwebsite\Excel\Concerns\WithHeadingRow;
- class UsersImport implements ToArray
- {
- public function array(array $array)
- {
- dump($array);
- }
- /**
- * @param array $row
- *
- * @return \Illuminate\Database\Eloquent\Model|null
- */
- public function model(array $row)
- {
- dump($row);
- }
- public function map($row): array
- {
- return [
- 'name' => $row[0],
- 'title' => $row[1],
- ];
- }
- public function mapping(): array
- {
- return [
- 'name' => 'B1',
- ];
- }
- public function rules(): array
- {
- return [
- // 'name' => Rule::in(['patrick@maatwebsite.nl']),
- ];
- }
- public function customValidationMessages()
- {
- return [
- '1.in' => '自定义',
- ];
- }
- }
|