PHP code example of distinctm / laravel-data-sync
1. Go to this page and download the library: Download distinctm/laravel-data-sync library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
distinctm / laravel-data-sync example snippets
User::updateOrCreate([
'email' => '[email protected] ',
],[
'name' => 'Ferris Bueller',
'properties->title' => 'Leisure Consultant',
'phone_numbers->mobile' => '555-555-5555',
'department_id' => Department::where('name', 'Management')
->where('location_id', Location::where('name', 'Chicago')->first()->id)
->first()
->id,
]);
Role::updateOrCreate(['slug' => 'update-student-records']);
Role::updateOrCreate(['slug' => 'borrow-ferrari']);
Role::updateOrCreate(['slug' => 'destroy-ferrari']);
RoleUser::updateOrCreate([
'user_id' => User::where('email', '[email protected] ')->first()->id,
'role_id' => Role::where('slug', 'update-student-records')->first()->id,
]);
RoleUser::updateOrCreate([
'user_id' => User::where('email', '[email protected] ')->first()->id,
'role_id' => Role::where('slug', 'borrow-ferrari')->first()->id,
]);
RoleUser::updateOrCreate([
'user_id' => User::where('email', '[email protected] ')->first()->id,
'role_id' => Role::where('slug', 'destroy-ferrari')->first()->id,
]);
php artisan data:export User --criteria=name --criteria=email --except=id