<?php
// This is Laravel Helper Class..
//
// READ ME:
//
// Created this prop, just because, Laravel collection errors incase a direct
// access to its members fails. using `prop` it will just return `null` incase
// a member of the collection does not exists, and if accessing it as a method
// you can convert its value as a proper type, like `float, int, integer, boolean,
// dateTime, string, array, object, double` this can easily be extended by
// adding / modifying the a function in `ObjectPropDataType::checkCustomType`
// its not as best implementation but you got the picture.
//
// Sample simple Usage:
$user = prop(User::find(1));
// Shows raw value; string
dd($x->created_at);
// Shows value with DateTime DataType
dd($x->created_at()->toDateTime());
// Accessing meta or if using 'laravel-metable'
// array is casted as a new `ObjectProp`
dd($x->meta->first());
|