Step 1 : create model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Yourmodelname extends Model
{
protected $table = 'your_table_name';
}
Step 2 : Create Provider and Go to provider folder and copy past below
code
<?php
namespace App\Providers;
use App\Modelname; // write model name here
use Illuminate\Support\ServiceProvider;
class Providername extends ServiceProvider
{
public function boot()
{
view()->composer('*',function($view){
$view->with('arrayname', Modelname::all());
});
}
}
Step 3 : Register your provide which we are created
Go to config/app.php and add below line
App\Providers\Providername::class,
Step 4 : Now you can used Array which we created in provider
Open your view and copy past this code
@foreach ($arrayname as $data)
<option value="{{ $data->id }}" >{{ $data->key_name }}</option>
@endforeach