PHP code example of hongxunpan / eloquent-projection
1. Go to this page and download the library: Download hongxunpan/eloquent-projection 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/ */
use HongXunPan\EloquentProjection\FieldOverrideRule;
use HongXunPan\EloquentProjection\ProjectionApplier;
use HongXunPan\EloquentProjection\ProjectionProfile;
$profile = new ProjectionProfile(
overrides: [
new FieldOverrideRule(
'mobile_phone_masked',
'mobile_phone',
$canViewMobileFull,
true,
true
),
],
);
return ProjectionApplier::projectModel($submitRecord, $profile);
new FieldOverrideRule(
'mobile_phone_masked',
'mobile_phone',
$canViewMobileFull,
true,
true
)
use HongXunPan\EloquentProjection\FieldOverrideRule;
use HongXunPan\EloquentProjection\ProjectionApplier;
use HongXunPan\EloquentProjection\ProjectionProfile;
$profile = new ProjectionProfile(
overrides: [
new FieldOverrideRule(
'mobile_phone_masked',
'mobile_phone',
$canViewMobileFull,
true,
true
),
],
);
ProjectionApplier::applyRelation($records, 'alumniCard', $profile);
$profile = new ProjectionProfile(
overrides: [
new FieldOverrideRule(
'phone_masked',
'phone',
$canViewPhoneFull,
true,
true
),
],
);
return ProjectionApplier::projectModel($user, $profile);