mercredi 4 juillet 2018

How to create New model object by reference of another Model

I have a function in which I take model as parameter to create slug value from that model values and after creating slug i want to check existence of that in same table.

public static function slug_it($model = null)
{
  if(!empty($model)) {
    #from model
    $keys = [/*priority => key to find*/
        1 => 'name', 2 => 'item', 4 => 'title', 3 => 'code', 5 => 'company', 6 => 'code_name', 7 => 'country', 8 => 'city', 9 => 'state', 10 => 'username', 11 => 'first_name', 12 => 'last_name',];
    /* suppose i have slug */
    $slug = 'item_erp5511'; 

    /*slug or sku*/
  } else {

  }
}

Suppose Model is of item table and I want to find slug in "slug" col of that table but i only have Model Object of that table.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire