1. Go to this page and download the library: Download sereny/nova-cep 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/ */
sereny / nova-cep example snippets
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('addresses', function (Blueprint $table) {
$table->id('id')->primary();
$table->foreignId('owner')->constrained()->cascadeOnDelete();
$table->string('postcode');
$table->string('street');
$table->string('details')->nullable();
$table->string('district')->nullable();
$table->string('number')->nullable();
$table->json('city');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('addresses');
}
};
namespace App\Nova;
use Laravel\Nova\Fields\Hidden;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
use Sereny\NovaCep\Fields\Cep;
class Address extends Resource
{
/**
* The model the resource corresponds to.
*
* @var class-string<\App\Models\Address>
*/
public static $model = \App\Models\Address::class;
/**
* The single value that should be used to represent the resource when being displayed.
*
* @var string
*/
public static $title = 'street';
/**
* The columns that should be searched.
*
* @var array
*/
public static $search = [
'street',
'postcode',
'district'
];
/**
* Get the fields displayed by the resource.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @return array
*/
public function fields(NovaRequest $request)
{
return [
Cep::make(__('Postcode'), 'postcode')
->
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.