Mokrani
3 months ago
374
4
Laravel

Object of class Generator could not be converted to string

Posted 3 months ago by Mokrani

Hello

Im trying to use the NextApps UniqueCodes Package and when i'm trying to insert the value to my db i have this error (Object of class Generator could not be converted to string)

This is my store function :

    $course = new Courses();
    
    
   $codes = (new UniqueCodes())
    ->setPrime(184259)
    ->setMaxPrime(7230323)
    ->setCharacters('LQJCKZM4WDPT69S7XRGANY23VBH58F1')
    ->setLength(6)
    ->generate(1, 100);

    $course->numero = $codes;
    $course->idclient = $request->input('idclient');
    $course->idcoursier = $request->input('idcoursier');
    $course->pointdep = $request->input('pointdep');
    $course->destination = $request->input('destination');
    $course->type = $request->input('type');
    $course->nbrbon = $request->input('nbrbon');
    $course->daterecup = $request->input('daterecup');
    $course->heurerecup = $request->input('heurerecup');
    $course->description = $request->input('description');
    $course->save();
    return redirect('/admin/courses')->with('status1',' ');

}

i don't know why i have this error i think because the package is returning a object and i want to insert it in a string db column

If any one have a solution it will be helpful Thank you

Please sign in or create an account to participate in this conversation.