-
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
1f5b7ce
commit 077fc31
Showing
16 changed files
with
251 additions
and
754 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace App\Exports; | ||
|
||
use App\Models\barang; | ||
use Maatwebsite\Excel\Concerns\FromCollection; | ||
|
||
class barangExport implements FromCollection | ||
{ | ||
/** | ||
* @return \Illuminate\Support\Collection | ||
*/ | ||
|
||
protected $search; | ||
public function __construct(string $search) | ||
{ | ||
$this->search = $search; | ||
} | ||
|
||
public function collection() | ||
{ | ||
$allData; | ||
if($this->search!=null || $this->search!=""){ | ||
$allData=barang::search($this->search); | ||
}else{ | ||
$allData=barang::all(); | ||
} | ||
|
||
foreach($allData as $data){ | ||
$data->getAttributes(); | ||
if($data->foto!=null || $data->foto!=""){ | ||
$data->foto = asset("/storage/lampiran/".$data->foto); | ||
}else{ | ||
$data->foto = "Tidak Ada Lampiran"; | ||
} | ||
} | ||
return collect([ | ||
['id','Kode Barang', 'Nama Barang', 'Tanggal Pembelian', 'Kategori', 'Keterangan', 'Link Foto', 'Created At', 'Updated At'], | ||
$allData | ||
]); | ||
} | ||
} |
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
Oops, something went wrong.