Skip to content

Instantly share code, notes, and snippets.

@mazfreelance
Created September 6, 2018 03:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mazfreelance/0f00c41a1a9f11358bf87a5878a0a945 to your computer and use it in GitHub Desktop.
Save mazfreelance/0f00c41a1a9f11358bf87a5878a0a945 to your computer and use it in GitHub Desktop.
Dynamic List Laravel
//Model
namespace App;
use Illuminate\Database\Eloquent\Model;
class ModelName extends Model
{
protected $table = 'table_name_dB';
}
//Provider
namespace App\Providers;
use App\ModelName;
use Illuminate\Support\ServiceProvider;
class ProviderName extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
view()->composer('*', function($view){
$view->with('array_name', ModelName::all());
});
}
...
//config/app.php
App\Providers\ProviderName::class,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment