mardi 2 février 2016

laravel updateOrCreate() with dynamic table

I'm working with project where tables are created all the time depending on user adding new properties, so for my model i have below

    class Hotel extends Model
{
    public function __construct($hotel)
    {
        $this->table = $hotel;
    }

    protected $fillable = ['date', 'sold', 'sold_diff', 'rev', 'rev_diff', 'row', 'date_col', 'sold_col', 'rev_col'];

}

and i can use the table in controller by doing

$hotel_table = new Hotel($table);

but i like to use Model::updateOrCreate() when I'm adding or updating rows in table, and I'm not sure how to do that.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire