Category : builder

I updated my Symfony 5.3 project to use PHP attributes instead of annotations. But, since that, when I run php bin/console cache:clear, I’ve the following errors : 14:25:14 WARNING [app] Failed to generate ConfigBuilder for extension LiipTestFixturesBundleDependencyInjectionLiipTestFixturesExtension. ["exception" => SymfonyComponentDependencyInjectionExceptionEnvNotFoundException { …},"extensionClass" => "LiipTestFixturesBundleDependencyInjectionLiipTestFixturesExtension"] 14:25:14 WARNING [app] Failed to generate ConfigBuilder for extension SymfonyUXChartjsDependencyInjectionChartjsExtension. ["exception" ..

Read more

I have pivot table vacancy_tag. I tried different options (value,select, lists and etc), but didn’t go further than that. My request: Vacancy::where(‘id’,1)->with([‘tags’ => function ($q){ $q->select(‘tags.id’)->pluck(‘id’); }])->get()->toArray(); return this: … "tags" => array:2 [▼ 0 => array:1 [▼ "id" => 1 ] 1 => array:1 [▼ "id" => 2 ] … but need this: "tags" ..

Read more

Let’s say if have a model called ReportType with some fields (id, name, created_at). In my controller (ReportTypeController.php) <?php namespace AppHttpControllers; class HomeController extends Controller { public function index() { $reportType = ReportType::whereNotNull(‘created_at’); $this->addSomeConditions($reportType); return $reportType; } private function addSomeConditions($reportType) { $reportType->whereIn(‘id’, [1, 2, 3]); } } The $reportType variable in index will have whereIn ..

Read more

So Basically i have the model foo: protected $with = [‘bars’]; public function bars() { return $this->morphMany(bar::class, ‘barable’); } And the model bar: public function barable() { return $this->morphTo(); } Now my question is, if i want to load foo via bar: Bar::find(1)->with([‘barable.something.this’])->get(); I get the foo table alongside with the corresponding bar. Now because ..

Read more