You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What I want is to list the usage field of this object. It's an array as you can see and I couldn't find any similar usage in the documentation.
I tried to do it like this:
class PublishEngineLogsLayout extends Table
{
private $detailsScreen;
public function __construct()
{
$this->detailsScreen = new AccountStatisticsScreen;
}
public function __call($method, $args)
{
$this->detailsScreen->$method($args[0]);
}
/**
* Data source.
*
* The name of the key to fetch it from the query.
* The results of which will be elements of the table.
*
* @var string
*/
protected $target = 'publishEngine';
/**
* Get the table cells to be displayed.
*
* @return TD[]
*/
protected function columns(): array
{
return [
TD::make('usage.service', 'Service')
->align(TD::ALIGN_CENTER)
->width('70px'),
TD::make('usage.type', 'Type')
->align(TD::ALIGN_CENTER)
->width('70px'),
TD::make('usage.taskCount', 'Task Count')
->align(TD::ALIGN_CENTER)
->width('70px'),
TD::make('usage.totalDuration', 'Total Durations')
->align(TD::ALIGN_CENTER)
->width('70px')
];
}
}
And this is the model I used:
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Orchid\Filters\Filterable;
use Orchid\Screen\AsSource;
class PublishEngineMonthlyLogs extends Model
{
use AsSource, Filterable;
// Model's input parameters
protected $fillable = [
'campaignDesignerAccountId',
'remoteAccountId',
'usage',
'month'
];
protected $casts = [
'usage' => 'array'
];
// Sorting parameters
protected $allowedSorts = [
'month'
];
// Permission of filtering fields with texts
protected $allowedFilters = [
'month',
'campaignDesignerAccountId'
];
}
I learned Laravel with Orchid for the first time, so I am not very used to the model system. I wonder if I need to add nested structures like in this example to the model. If so, can you simply give me an example?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
This is my object:
What I want is to list the
usage
field of this object. It's an array as you can see and I couldn't find any similar usage in the documentation.I tried to do it like this:
And this is the model I used:
I learned Laravel with Orchid for the first time, so I am not very used to the model system. I wonder if I need to add nested structures like in this example to the model. If so, can you simply give me an example?
Beta Was this translation helpful? Give feedback.
All reactions