1. Go to this page and download the library: Download anaseqal/nova-import library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
anaseqal / nova-import example snippets
use Anaseqal\NovaImport\NovaImport;
// ...
public function tools()
{
return [
new NovaImport,
// ...
];
}
namespace App\Nova\Actions;
use Illuminate\Bus\Queueable;
use Anaseqal\NovaImport\Actions\Action;
use Illuminate\Support\Collection;
use Laravel\Nova\Fields\ActionFields;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Laravel\Nova\Fields\File;
use App\Imports\UsersImport;
use Maatwebsite\Excel\Facades\Excel;
class ImportUsers extends Action
{
use InteractsWithQueue, Queueable, SerializesModels;
/**
* Indicates if this action is only available on the resource detail view.
*
* @var bool
*/
public $onlyOnIndex = true;
/**
* Get the displayable name of the action.
*
* @return string
*/
public function name() {
return __('Import Users');
}
/**
* @return string
*/
public function uriKey() :string
{
return 'import-users';
}
/**
* Perform the action.
*
* @param \Laravel\Nova\Fields\ActionFields $fields
* @return mixed
*/
public function handle(ActionFields $fields)
{
Excel::import(new UsersImport, $fields->file);
return Action::message('It worked!');
}
/**
* Get the fields available on the action.
*
* @return array
*/
public function fields()
{
return [
File::make('File')
->rules('
/**
* Get the actions available for the resource.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function actions(Request $request)
{
return [new Actions\ImportUsers];
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.