Thank you so much. This video helped me to resolve one of my ID Generating issues.
@jamalbayacine3829
3 жыл бұрын
I think you have to note these instructions : if($last_number_length>$length){$og_length=0;} else{$og_length=$length-$last_number_length;} thank you for this video.
@nelli.khimura
Жыл бұрын
very helpful. Thank yoyu
@ທາງລັດ
2 жыл бұрын
This is great tutorial video, thanks for sharing.
@sawastacks
2 жыл бұрын
Glad it was helpful!
@eliebea1307
Жыл бұрын
Thanks 🔥
@sawastacks
Жыл бұрын
Hi Elie Bea. you can use my package: github.com/mbere250/laravel-idify for creating custom ID. That package will do the same to this.
@SagradaBiblia2050
3 жыл бұрын
Thank you so much for your help
@sawastacks
3 жыл бұрын
merci beaucoup!
@Defaulttt
3 жыл бұрын
You just earned a sub. I hope you'll do more in the future! Thank you!
@sawastacks
3 жыл бұрын
Thanks for the sub!
@ronanjoziah6966
3 жыл бұрын
i realize I am pretty off topic but does anyone know of a good place to watch new movies online ?
@caseymyles7202
3 жыл бұрын
@Ronan Joziah lately I have been using FlixZone. You can find it by googling =)
@Alerodb2020
2 жыл бұрын
In laravel 9 with PHP 8.1.2 it shows this error “Unsupported operand types: string / int” when saving for the first time. change the line $code = substr($data->$trow, strlen($prefix)+1); to $code = (int)(substr($data->$trow, strlen($prefix)+1)); With that it works for me, thank you very much for the idea of the IDGenerator.
@sawastacks
2 жыл бұрын
Hello alexander. I hadn't tried it in laravel 9. Thank you so much for the correction
@blank_7593
2 жыл бұрын
thank you for your help :)
@alphonsesossou4283
3 жыл бұрын
Thanks, excellent and really useful tutorial.
@sawastacks
3 жыл бұрын
Glad you enjoyed it!
@blank_7593
2 жыл бұрын
how to create 2 different idgenerator (different prefix) on the same table. Like STD-0001, STD-0002 then in another prefix ABC-0001, ABC-0002 and so on. can you help me?
@kevinwakhisi7001
3 жыл бұрын
damn another great video you just earn my sub
@ToussaintMufungizi
3 жыл бұрын
Since it is capturing max ID What happens if two users are trying to insert new student simultaneously????
@voskilltheentertainer2564
2 жыл бұрын
this tutorial saved me.how can i pass the custom id generated to an api endpoint?
@azmmifauzy2195
3 жыл бұрын
Bro i was succeed generating Id like INV-00001 .. but when i try to get on my view... it just show 0... so how to get the original value of my id?
@naufalnadaandesa7799
2 жыл бұрын
I have an error its "Attempt to read property "no" on null". "no" is like the number id of document and the error was in this line : $code=(substr($data->$trow, strlen($prefix)+1)); how to solve this sir, thanks before
@kevinwakhisi7001
3 жыл бұрын
i have a question, how can i reset the counter yearly or monthly, lets say STD-2112001 then next year STD-2201001
@seemabaloda6250
3 жыл бұрын
if i use this code using facade then facade is define in place of $model.plz tell
@ajith1786
3 жыл бұрын
can you please add this code to Github repository. Nice video Thanks
@code4u620
3 жыл бұрын
hi irebe i need help for the same situation where i have a employee-id i need to be save as emp001 but i a m failing to do it
@sawastacks
3 жыл бұрын
Just change this function like this
@sonihidayatulloh9242
Жыл бұрын
how first number id i want first number one not a zero how i can try in code, please help me
@sawastacks
Жыл бұрын
Can you try our laravel packages: github.com/mbere250/laravel-idify
@alanali7177
3 жыл бұрын
Hi Irebe, thank you so much for your video, can you please tell me and how to fix this error, ErrorException Required parameter $prefix follows optional parameter $length I use same your code in helper class.
@sawastacks
3 жыл бұрын
make sure that this helper function has all parameters public static function IDGenerator($model, $trow, $length = 4, $prefix){} also in controller: $student_id = Helper::IDGenerator(new Student, 'student_id', 2, 'STD'); /** Generate id */
@alanali7177
3 жыл бұрын
@@sawastacks Thank you so much for your support, much appreciated. I checked, but I have same error, This my code: in contoller: function insertDoctor(Request $request){ $request->validate([ 'name'=>'required', ]); $name = $request->name; $email = $request->email; $phone = $request->phone; $address = $request->address; $commission = $request->commission; $doctor_id = mi::IDGenerator(new doctors, 'doctor_id', 2, 'Dr'); /** Generate id */ $q = new doctors; $q->doctor_id = $doctor_id; $q->name = $name; $q->email = $email; $q->phone = $phone; $q->address = $address; $q->commission = $commission; $save = $q->save(); if($save){ return back()->with('success','New studen has been added'); }else{ return back()->with('faile','Something went wrong'); } } And I use custom helper class and I import: use App\mi\mi; inside ( mi ) class, I use same your code without edit it. public static function IDGenerator($model, $trow, $length = 4, $prefix){} And also make a route: Route::post('insertdoctor',[AdminController::class,'insertDoctor'])->name('admin.insertDoctor'); and call that route in form: action="{{ route('admin.insertDoctor') }}" And I import also model class: use App\Models\doctors; this is code in model class class doctors extends Model { use HasFactory; protected $primaryKey = 'id'; protected $fillable = [ 'doctor_id', 'name', 'email', 'phone', 'address', 'commission' ]; } I think everything fine, but I don't know why give me that error.
@sawastacks
3 жыл бұрын
@Aya Media Oooh! Am going to check that
@alanali7177
3 жыл бұрын
@Aya Media it's working, Thank you so much sir.
@stephenawuor8817
3 жыл бұрын
Hello, Thanks for the great video. Am getting an error though whenever I try to add a new student. Could you kindly assist?, My error is "Trying to get property 'STD-00001' of non-object"
@sawastacks
3 жыл бұрын
Let me check
@stephenawuor8817
3 жыл бұрын
@@sawastacks Thank you, would you want to see my code?
@sawastacks
3 жыл бұрын
@@stephenawuor8817 Yeah. show me
@stephenawuor8817
3 жыл бұрын
@@sawastacks This is my code in the StudentsController, This function "add_student" is meant to add a new student. So I used your method to generate a random ID. public function add_student(request $request){ $this->validate ($request, [ 'a_date' => ['required'], 'a_year' => ['required'], 'a_grade' => ['required'], 'fname' => ['required', 'string', 'max:255'], 'mname' => ['string', 'max:255'], 'lname' => ['required', 'string', 'max:255'], 'gender' => ['required'], 'dob' => ['required'], 'c_school' => ['string', 'max:255'], 'parent' => ['string', 'max:255'], 'p_relation' => ['string'], ],[ 'fname.required' => "The :value First Name is required.", 'lname.required' => "The :value Last Name is required.", 'a_grade.required' => "The :value Admission Grade is required.", ]); $newstudent=new Students(); $Student_id = Helper::IDGenerator(new Students, 'Student_id', 4, 'STD'); $newstudent->a_date=$request->input('a_date'); $newstudent->a_year=$request->input('a_year'); $newstudent->a_grade=$request->input('a_grade'); $newstudent->fname=$request->input('fname'); $newstudent->mname=$request->input('mname'); $newstudent->lname=$request->input('lname'); $newstudent->gender=$request->input('gender'); $newstudent->dob=$request->input('dob'); $newstudent->c_school=$request->input('c_school'); $newstudent->parent=$request->input('parent'); $newstudent->p_relation=$request->input('p_relation'); $newstudent->Student_id->$Student_id; $newstudent->save(); return redirect ('/admin_students')->with('success', 'New Student Successfully Added!'); }
@sawastacks
3 жыл бұрын
@Stephen Awuor 1) student_id (s) must be lower case on this line: $Student_id = Helper::IDGenerator(new Students, 'Student_id', 4, 'STD'); to $Student_id = Helper::IDGenerator(new Students, 'student_id', 4, 'STD'); 2) make sure that you import this on this controller: use App\Helpers\Helper; use App\Models\Student; use Validator; 3) Watch how you can create custom helper: kzitem.info/news/bejne/rqhrzoakrGiGaGU
@ThuyLe-gu7cy
3 жыл бұрын
Hi Got This ErrorException A non-numeric value encountered, when i add 3 or 4 more student at the code $actia_last_number = ($code/1)*1; do you know how to solve this problem?
@sawastacks
3 жыл бұрын
Have you check $actia_last_number => $actial_last_number ?
@ThuyLe-gu7cy
3 жыл бұрын
@@sawastacks I solve the problem, because about database on mysql, i change to int -> varchar then is work
@sawastacks
3 жыл бұрын
@@ThuyLe-gu7cy nice! I already add link of this on description.
@abeselomlandber9290
3 жыл бұрын
Thank you so much! i'm getting "Unsupported operand types: string / int" error on helper.php where the line $actial_last_number = ($code/1)*1; is found.
@sawastacks
3 жыл бұрын
$actual_last_number = ($code/1)*1;
@saimazainab6995
3 жыл бұрын
I'm also getting the same error.
@targetx1733
2 жыл бұрын
You have to do cast $core=(int) $core
@praveenkusugal3279
3 жыл бұрын
1364 Field 'customer_id' doesn't have a default value (SQL: insert into `contacts`
@alphonsesossou4283
3 жыл бұрын
$table->string(''customer_id')->nullable(); in migration file
@nathasyapradita4012
3 жыл бұрын
Hi, how to change the start number from "0" To "1" So the first number is 00001 not 00000?
@alphonsesossou4283
3 жыл бұрын
Use this code: if(!$data){ $og_length = $length; $last_number = 1; }else{..........
hello, i have problem can you help me? Undefined variable: data my code : controller public function store(Request $request) { $kode_barang = Helper::IDGenerator(new Stok, 'kode_barang', 5, 'KB-'); Stok::Create([ 'kode_barang' => $kode_barang, 'nama' => $request->nama, 'kategori_id' => $request->kategori_id, ]); return redirect('/stok-barang'); }
Пікірлер: 65