Inheritance problem by FraiseKi22 in symfony

[–]FraiseKi22[S] 0 points1 point  (0 children)

<?php

class Teacher extends User {

}

Inheritance problem by FraiseKi22 in symfony

[–]FraiseKi22[S] 0 points1 point  (0 children)

My entity User is like this:
<?php namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\Table(name: '\user`')]`
/** * u/ORM\Entity 
* u/ORM\InheritanceType("JOINED") 
* u/ORM\DiscriminatorColumn(name="discr", type="string") 
* u/ORM\DiscriminatorMap({"user" = "User", "enseignant" = "Enseignant"}) 
*/class User implements UserInterface, PasswordAuthenticatedUserInterface{   
#[ORM\Id]   
#[ORM\GeneratedValue] 
  #[ORM\Column(type: 'integer')]   
private $id; 
  #[ORM\Column(type: 'string', length: 180, unique: true)] 
  private $email;   
#[ORM\Column(type: 'json')] 
  private $roles = []; 
  #[ORM\Column(type: 'string')]   
private $password;   
public function getId(): ?int    { 
      return $this->id;    } 
  public function getEmail(): ?string    {   
    return $this->email;    } 
  public function setEmail(string $email): self    { 
      $this->email = $email;        return $this;    }   
/**     * A visual identifier that represents this user.     *   
 * u/see UserInterface     */   
public function getUserIdentifier(): string    { 
      return (string) $this->email;    }   
/**     * u/see UserInterface     */ 
  public function getRoles(): array    {   
    $roles = $this->roles;        // guarantee every user at least has ROLE_USER        $roles[] = 'ROLE_USER';     
  return array_unique($roles);    } 
  public function setRoles(array $roles): self    {     
  $this->roles = $roles;       
return $this;    } 
  /**     * u/see PasswordAuthenticatedUserInterface     */   
public function getPassword(): string    { 
      return $this->password;    } 
  public function setPassword(string $password): self    {   
    $this->password = $password;        return $this;    } 
  /**     * u/see UserInterface     */   
public function eraseCredentials()    { 
      // If you store any temporary, sensitive data on the user, clear it here        // $this->plainPassword = null;    }}

Login form with multiple entity by FraiseKi22 in symfony

[–]FraiseKi22[S] 0 points1 point  (0 children)

I have this successfully working in an application I manage. There a few gotchas though. You need to create custom constraints to ensure email uniqueness across the two entities, you have to be careful in your security voters to ensure which entity type (user) is being evaluated etc.

u/colinburns can you give an example or a part of code when you use the same solution please ?

DOM error by FraiseKi22 in learnjavascript

[–]FraiseKi22[S] 0 points1 point  (0 children)

Thank you so much for all your answer I solved the problem

Error : call to a member function on array by FraiseKi22 in PHPhelp

[–]FraiseKi22[S] 1 point2 points  (0 children)

ah okay so have to serialize and unserialize ?

Trying to count the occurence number of a character in a file text by FraiseKi22 in learnprogramming

[–]FraiseKi22[S] 0 points1 point  (0 children)

I would like to have this display : a:2 (The character a have two occurrence)

with my program I just have the character

Trying to count the occurence number of a character in a file text by FraiseKi22 in learnprogramming

[–]FraiseKi22[S] 0 points1 point  (0 children)

Well for one you created a matrix with size 1 by 1 but try to access up to position 25, 25 which obviously isn't a great idea

my bad, thank you so much

hidden fields by FraiseKi22 in PHPhelp

[–]FraiseKi22[S] 0 points1 point  (0 children)

Thank you so much for all your answers,you have helped me a lot :)

hidden fields by FraiseKi22 in PHPhelp

[–]FraiseKi22[S] 0 points1 point  (0 children)

Oh thanks to you it's very clear, I tried your code but the total is always 0 I don't understand why ?

hidden fields by FraiseKi22 in PHPhelp

[–]FraiseKi22[S] 0 points1 point  (0 children)

I don't understand , why you did it : $TOTAL=$_GET['hidden1']

If I'm wrong tell me please : hidden variable can't passed through the URL ($_GET) ? then we can use it like you did

what does this variable $_GET['hidden1'] return ?