Array Helper #35178
Answered
by
crynobone
wisnubaldas
asked this question in
Q&A
Array Helper
#35178
-
Hi..... I made a database backup on migrate, when I use the
protected function backup($tName)
{
if (Schema::hasTable($tName))
{
$file = database_path('seeders/data/'.$tName.'.csv');
$table = DB::table($tName)->get();
$writer = Writer::createFromPath($file, 'w+');
$writer->insertOne(['id','name','email','email_verified_at','password','remember_token']);
if($table->count() > 0)
{
foreach ($table->toArray() as $v) {
$filtered = Arr::except($v, ['created_at','updated_at']);
dd($filtered);
// $writer->insertAll((array)$v); //using an array
}
}
}
} here is a snippet of error code: Rolling back: 2014_10_12_000000_create_users_table
ErrorException
array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead
at vendor/laravel/framework/src/Illuminate/Collections/Arr.php:155
151▕ if ($array instanceof ArrayAccess) {
152▕ return $array->offsetExists($key);
153▕ }
154▕
➜ 155▕ return array_key_exists($key, $array);
156▕ }
157▕
158▕ /**
159▕ * Return the first element in an array passing a given truth test.
+3 vendor frames
4 database/migrations/2014_10_12_000000_create_users_table.php:52
Illuminate\Support\Arr::except(Object(stdClass))
5 database/migrations/2014_10_12_000000_create_users_table.php:38
CreateUsersTable::backup("users") |
Beta Was this translation helpful? Give feedback.
Answered by
crynobone
Nov 11, 2020
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
wisnubaldas
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Arr::except()
is meant to used witharray
or object that implementsArrayAccess