Example #1
0
 /**
  * Extract the model instance and model keys from the given parameters.
  *
  * @param  string|\Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection  $model
  * @param  array|null  $keys
  * @return array
  */
 public static function extractModelAndKeys($model, array $keys = null)
 {
     if (is_null($keys)) {
         if ($model instanceof Model) {
             return [$model, [$model->getKey()]];
         }
         if ($model instanceof Collection) {
             return [$model->first(), $model->modelKeys()];
         }
     } else {
         if (is_string($model)) {
             $model = new $model();
         }
         return [$model, $keys];
     }
 }