-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebcc680
commit cab0c30
Showing
8 changed files
with
247 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Tripteki\SettingMenu\Http\Resources; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Response; | ||
use Illuminate\Http\Resources\Json\JsonResource; | ||
|
||
class MenudetailResource extends JsonResource | ||
{ | ||
/** | ||
* @param \Illuminate\Http\Request $request | ||
* @return array | ||
*/ | ||
public function toArray($request) | ||
{ | ||
return [ | ||
|
||
"bar" => $this->bar, | ||
"menu" => $this->menu, | ||
"category" => $this->category, | ||
"icon" => $this->icon, | ||
"title" => $this->title, | ||
"description" => $this->description, | ||
]; | ||
} | ||
}; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace App\Exports\Settings\Menus; | ||
|
||
use Tripteki\SettingMenu\Models\Admin\Detailmenu; | ||
use Tripteki\SettingMenu\Http\Resources\MenudetailResource; | ||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; | ||
use Maatwebsite\Excel\Concerns\ShouldAutoSize; | ||
use Maatwebsite\Excel\Concerns\WithStyles; | ||
use Maatwebsite\Excel\Concerns\WithHeadings; | ||
use Maatwebsite\Excel\Concerns\FromArray; | ||
|
||
class MenuExport implements FromArray, ShouldAutoSize, WithStyles, WithHeadings | ||
{ | ||
/** | ||
* @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $sheet | ||
* @return array | ||
*/ | ||
public function styles(Worksheet $sheet) | ||
{ | ||
return [ | ||
|
||
1 => [ "font" => [ "bold" => true, ], ], | ||
]; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function headings(): array | ||
{ | ||
return [ | ||
|
||
"Bar", | ||
"Menu", | ||
"Category", | ||
"Icon", | ||
"Title", | ||
"Description", | ||
]; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function array(): array | ||
{ | ||
return MenudetailResource::collection(Detailmenu::all())->resolve(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace App\Imports\Settings\Menus; | ||
|
||
use Tripteki\SettingMenu\Contracts\Repository\Admin\ISettingMenuDetailRepository; | ||
use App\Http\Requests\Admin\Settings\Menus\MenuStoreValidation; | ||
use Maatwebsite\Excel\Concerns\WithStartRow; | ||
use Maatwebsite\Excel\Concerns\ToCollection; | ||
use Illuminate\Support\Collection; | ||
use Illuminate\Support\Facades\Validator; | ||
|
||
class MenuImport implements ToCollection, WithStartRow | ||
{ | ||
/** | ||
* @return int | ||
*/ | ||
public function startRow(): int | ||
{ | ||
return 2; | ||
} | ||
|
||
/** | ||
* @param \Illuminate\Support\Collection $rows | ||
* @return void | ||
*/ | ||
protected function validate(Collection $rows) | ||
{ | ||
$validator = (new MenuStoreValidation())->rules(); | ||
|
||
Validator::make($rows->toArray(), [ | ||
|
||
"*.0" => $validator["bar"], | ||
"*.1" => $validator["menu"], | ||
"*.2" => $validator["category"], | ||
"*.3" => $validator["icon"], | ||
"*.4" => $validator["title"], | ||
"*.5" => $validator["description"], | ||
|
||
])->validate(); | ||
} | ||
|
||
/** | ||
* @param \Illuminate\Support\Collection $rows | ||
* @return void | ||
*/ | ||
public function collection(Collection $rows) | ||
{ | ||
$this->validate($rows); | ||
|
||
$menuAdminRepository = app(ISettingMenuDetailRepository::class); | ||
|
||
foreach ($rows as $row) { | ||
|
||
$menuAdminRepository->create($row[0], $row[1], [ | ||
|
||
"category" => $row[2], | ||
"icon" => $row[3], | ||
"title" => $row[4], | ||
"description" => $row[5], | ||
]); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters