mardi 21 juillet 2020

How to pass dynamic table name to model according user's input in Laravel

I have a project that the column_field is dynamic, it's generated according to the user's input. Now I want to set that table dynamically, according to the user's input also. And is this possible without doing php artisan migrate?

Here what I want to do inside my Model.

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Customer extends Model
{
    $tableName = 'users_input';

    protected $guarded = [];
    protected $table = $tableName;
    public $timestamps = false;
    protected $primaryKey = 'id';
}

Waiting for your suggestions.

Cheers



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2ONs8X3
via IFTTT

Aucun commentaire:

Enregistrer un commentaire