Entities relation, form builder
Date : March 29 2020, 07:55 AM
I wish this help you You have the answer in the error message displayed by Symfony: you need to persist the Topic entity AND the TopicContent entity. To do that you must define a cascade={"persist"} on the relation. Edit: if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$content = $entity->getTopicContent();
$em->persist($entity);
$em->persist($content);
$em->flush();
return $this->redirect($this->generateUrl('application_club_show', array('id' => $entity->getTopicId())));
}
|
Many to many relation and query builder
Date : March 29 2020, 07:55 AM
help you fix your problem You can try such DQL (or simillar). Please check Doctrine DQL documenationSELECT u FROM App\UserBundle\Entity\User u
INNER JOIN u.role r
LEFT JOIN u.distance d
WHERE r.id = 1 OR (r.id = 1 AND d IS NULL)
SELECT u.id
FROM user as u, user_role as ur
WHERE u.id=ur.user_id and ur.role_id=1
SELECT u FROM App\UserBundle\Entity\User u
INNER JOIN u.role r
WHERE r.id = 1
|
Laravel getting builder instead of relation
Date : March 29 2020, 07:55 AM
I wish this helpful for you answers() does return a HasMany object. However, because there is no add method on a HasMany object, Laravel resorts to PHP's __call magic method. public function __call($method, $parameters)
{
$result = call_user_func_array([$this->query, $method], $parameters);
if ($result === $this->query) {
return $this;
}
return $result;
}
$question->answers->add(new Answer([...]));
|
Laravel - Query builder get relation
Tag : php , By : Nick Coats
Date : March 29 2020, 07:55 AM
seems to work fine Is there any reason you are using the DB facade to pull data instead of the actual models? One issue your are having is that your polymorphic relationship is stored in the commentable_id / commentable_type field, while your function name is product. Laravel does some of its magic just by naming alone, so let's make sure the column names and polymorphic function names match up in the product model: public function commentable()
{
return $this->morphTo();
}
$themeProducts = Product::where('commentable_type', Theme::class)->get();
@foreach ($themeProducts as $themeProduct)
{{ $themeProduct->commentable->composer_package }}
@endforeach
|
What are the different builder widgets(Future Builder, Stream Builder, Layout builder, Listview Builder) in Flutter.?
Date : March 29 2020, 07:55 AM
I hope this helps you . A FutureBuilder behaves identically to a StreamBuilder configured with future?.asStream(), except that snapshots with ConnectionState.active may appear for the latter, depending on how the stream is implemented. A StreamBuilder can be used with data of Firebase, Sensor Events and Network Connection status @override
Widget build(BuildContext context) {
return Container(
child: FutureBuilder(
future: getPosts(),
builder: (_, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text("Loading..."),
SizedBox(
height: 50.0,
),
CircularProgressIndicator()
],
),
);
} else {
return ListView.builder(
itemCount: snapshot.data.length,
itemBuilder: (_, index) {
return ListTile(
title: Text(snapshot.data[index].data["title"]),
onTap: () => navigateToDetail(snapshot.data[index]));
},
);
}
},
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: StreamBuilder<QuerySnapshot>(
stream: Firestore.instance.collection("posts").snapshots(),
builder:
(BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
if (snapshot.hasError) {
return new Text('Error: ${snapshot.error}');
}
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text("Loading..."),
SizedBox(
height: 50.0,
),
CircularProgressIndicator()
],
),
);
} else {
return ListView.builder(
itemCount: snapshot.data.documents.length,
itemBuilder: (_, index) {
return Card(
child: ListTile(
title: Text(
snapshot.data.documents[index].data["title"]), // getting the data from firestore
),
);
},
);
}
},
),
),
);
}
|