dadub

dadub

Member Since 2 Years Ago

Experience Points
700
Total
Experience

4,300 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
2
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 1
700 XP
May
24
5 days ago
Activity icon

Replied to Reach A Value Of An Object

Thank you reply.

I work a verly long time to find a solution, but nothing until now...

I think, the best way is to use the query 2 with the query 1:

Query 1

$informations_plante = DB::table('herbs')
            ->select('herbs.name as hname', 'herbs.sciname', 'herbs.id as herbid','hinteractions.id as hinteractionid','hinteractions.note as hinteractionnote','hinteractions.force_id','targets.name as targetname', 'forces.name as force_name')
            ->leftJoin('hinteractions', 'herbs.id', '=', 'herb_id')
            ->leftJoin('forces', 'forces.id', '=', 'force_id')
            ->leftJoin('targets', 'targets.id', '=', 'hinteractions.target_id')->where('herbs.id', $id)
            //add here query 2
            ->get();

Query 2

    $hinteractions_has_effects = DB::table('hinteraction_has_effects')
                     ->select(DB::raw('effect_id, hinteraction_id'))
                     ->where('hinteraction_id', '=', 1)
                     ->get();

Have you any idea please ?

Thank you in advance.

May
23
6 days ago
Activity icon

Replied to Guidelines For Posting On Laracasts.com

Hi, thank you for your great job.

I'm not ablet to display a picture with html tages.

I tried for example : Img

It does not work, any idea please ?

Thank you again.

Activity icon

Replied to Reach A Value Of An Object

Hello Michal,

Thank you very much for your help, indeed, I have now right information.

But, now, this data is not display anymore :

<td>
						
						{{$hinteraction->force_name}}
					</td>

That's because I have two queries, one LEFT JOIN and antoher many to many :

First query :

public function details($id)
    {
        //DD je récupère les informations de la plante
        //DB::enableQueryLog();
        $informations_plante = DB::table('herbs')
            ->select('herbs.name as hname', 'herbs.sciname','hinteractions.*','targets.name as targetname', 'forces.name as force_name')
            ->leftJoin('hinteractions', 'herbs.id', '=', 'herb_id')
            ->leftJoin('forces', 'forces.id', '=', 'force_id')
            ->leftJoin('targets', 'targets.id', '=', 'hinteractions.target_id')->where('herbs.id', $id)
            ->get();

Second query :

            $hinteractions_has_effects = Hinteraction::with('effects')->get();

and moreover, the displayed result is identical for each plant, it looks like it does not take into account the plant id.

Do you have any idea please ?

Thank you in advance.

David

May
22
1 week ago
Activity icon

Replied to Reach A Value Of An Object

Hello,

Thank you for your reply.

I edit my reply, this is my new code :

@foreach ($hinteractions_has_effects as $hinteractions_has_effect)
							@foreach($hinteractions_has_effect->effects as $effect)
								{{$effect->name}}	
							@endforeach
						@endforeach

It displays information, but ALL information now...

inhibiteur inducteur inducteur inhibiteur inducteur substrat

Thank you for your help.

Activity icon

Started a new Conversation Reach A Value Of An Object

Hi everybody,

I have this object :

Part 1 of the object :

https://www.dropbox.com/s/p5v9j3hj0yrqy0q/Capture%20d%27%C3%A9cran%202020-05-22%2017.15.01.png?dl=0

Part 2 of the object :

https://www.dropbox.com/s/s544edbkjo34lc0/Capture%20d%27%C3%A9cran%202020-05-22%2017.15.13.png?dl=0

I would like to get the value inside de border (see link Part 2 of the object).

My code :

It's a many to many, I have 2 models :

Model Hinteraction :

public function effects() {
        //DD: une hinteraction peut avoir plusieurs effets et un effet peut se trouver dans plusieurs hinteractions 
        return $this->belongsToMany(Effect::class, 'hinteraction_has_effects'); 
    }

Model Effect :

class Effect extends Model
{
    //DD: une hinteraction peut avoir plusieurs effets et un effet peut se trouver dans plusieurs hinteractions
    public function hinteractions() 
{ 
        return $this->belongsToMany(Hinteraction::class, 'hinteraction_has_effects'); 
}
            $hinteractions_has_effects = Hinteraction::with('effects')->get();

I tried to make this :

@foreach ($hinteractions_has_effects as $effect)
	{{$effect->name}}	
@endforeach

But I don't have no name.

Thank you in advance for your help.

May
21
1 week ago
Activity icon

Replied to Multiple Left Join, Information Not Present In The Result.

I found the soluton :

I justed put alias because I had two times name in the result :

$plante = DB::table('herbs') ->select('herbs.name as hname, herbs.sciname','hinteractions.*','targets.name as targetname') ->leftJoin('hinteractions', 'herbs.id', '=', 'herb_id') ->leftJoin('targets', 'targets.id', '=', 'hinteractions.target_id')->where('herbs.id', $id) ->get();

Thank you for your help.

Activity icon

Replied to Multiple Left Join, Information Not Present In The Result.

Hi,

Thank you for your quick reply.

#11 name is from target table :

https://www.dropbox.com/s/x84ilwzaaobwvsd/Capture%20d%27%C3%A9cran%202020-05-21%2010.56.48.png?dl=0

I need the target name and the herb name also... not only the target name.

I would like to display the query, is this possible ?

Thank you again.

Activity icon

Started a new Conversation Multiple Left Join, Information Not Present In The Result.

Hello everybody and thank you in advance for your help.

I try to create a multiple Left Joint query like this :

$plante = DB::table('herbs') ->select('herbs.*','hinteractions.*','targets.*') ->leftJoin('hinteractions', 'herbs.id', '=', 'herb_id') ->leftJoin('targets', 'targets.id', '=', 'hinteractions.target_id')->where('herbs.id', $id) ->get();

I got this result :

https://www.dropbox.com/s/ncig98n6e00p24q/Capture%20d%27%C3%A9cran%202020-05-21%2011.01.29.png?dl=0

That's great, but I'm surprised that I don't get information about the herb like the name of the plante (Ail), the sciname...

Like you can see, herb_id = 6, I don't have any information...

This is the content of my herbs record, it does not appear in the SQL result :

https://www.dropbox.com/s/zquw1nlzvx55418/Capture%20d%27%C3%A9cran%202020-05-21%2010.46.55.png?dl=0

Thank you in advance for your help.

May
20
1 week ago
Activity icon

Started a new Conversation Redirection Quand La Session Se Termine

Hi everybody,

When my session end, I have this message :

https://www.dropbox.com/s/6gtk3156p18sosr/Capture%20d%27%C3%A9cran%202020-05-20%2009.06.08.png?dl=0

I would like to add a redirection when the session is end.

Do you know where can I change that redirection ?

Thank you in advance.

May
19
1 week ago
Activity icon

Replied to Unable To Comeback To My Page (route)

Hi Michal,

Thank you, once again you resolved my problem.

Have a nice evening.

David

Activity icon

Started a new Conversation Unable To Comeback To My Page (route)

Hi,

I am in this page public/herbs/details_plante/8

When I click on my menu, I would like to go back to public/herb but I have this URL :

public/herbs/details_plante/herb

I don't understand why it replaces 8 by herb rather than go back to herb ?

This is my routes code :

[code]Route::get('herb/details_plante/{id}','[email protected]')->name('herbs.details');[/code]

[code]Route::get('/herb','[email protected]')->name('herbs.index');[/code]

Thank you in advance for your help.

May
17
1 week ago
Activity icon

Replied to Display Records From 2 Tables Through A Pivot Table

Hi Michal,

I try to use Laravel with all conventions... and I'm a little bit worry about what you said on yesterday :

But be careful, your pivot table herbs_have_forms is not as default laravel convention.

How have I to do to be OK with Laravel ?

Thank you for your help.

David

May
16
1 week ago
Activity icon

Replied to Display Records From 2 Tables Through A Pivot Table

Thank you so much Michal for all you are doing for everybody here...

I will read again your reply in a few hours and I will to understand.

All is working great tahnks to you.

Thank you again.

DAvid

Activity icon

Replied to Display Records From 2 Tables Through A Pivot Table

Great reply Michal, THANK YOU very much.

With this code

$herb = Herb::with('herb_forms')->get();

dd($herb); // this will be your collection of forms*/

I have this collection :

#items: array:10 [▼ 0 => App\Herb {#522 ▼ #connection: "mysql" #table: "herbs" #primaryKey: "id" #keyType: "int" +incrementing: true #with: [] #withCount: [] #perPage: 15 +exists: true +wasRecentlyCreated: false #attributes: array:6 [▼ "id" => 1 "name" => "Echinacées" "sciname" => "Echinacea sp." "created_at" => "2020-05-16 20:26:48" "updated_at" => "2020-05-16 20:26:48" "user_id" => 1 ] #original: array:6 [▶] #changes: [] #casts: [] #classCastCache: [] #dates: [] #dateFormat: null #appends: [] #dispatchesEvents: [] #observables: [] #relations: array:1 [▼ "herb_forms" => Illuminate\Database\Eloquent\Collection {#538 ▼ #items: array:1 [▼ 0 => App\HerbForm {#573 ▼ #connection: "mysql" #table: "herb_forms" #primaryKey: "id" #keyType: "int" +incrementing: true #with: [] #withCount: [] #perPage: 15 +exists: true +wasRecentlyCreated: false #attributes: array:4 [▼ "id" => 1 "name" => "Caps" "created_at" => "2020-05-16 20:26:48" "updated_at" => "2020-05-16 20:26:48" ] #original: array:6 [▶] #changes: [] #casts: [] #classCastCache: [] #dates: [] #dateFormat: null #appends: [] #dispatchesEvents: [] #observables: [] #relations: array:1 [▶] #touches: [] +timestamps: true #hidden: [] #visible: [] #fillable: [] #guarded: array:1 [▶] } ] } ] #touches: [] +timestamps: true #hidden: [] #visible: [] #fillable: [] #guarded: array:1 [▶] }

If I try to display herb_forms with this code :

dd($herb->forms); // this will be your collection of forms*/

I have this error :

Property [herb_forms] does not exist on this collection instance.

How can I please reach the herb_forms value ?

Thank you again for all.

David

Activity icon

Replied to Display Records From 2 Tables Through A Pivot Table

Hello Michal,

Thank you for your reply.

I tried your code, I have this message :

Call to undefined relationship [forms] on model [App\Herb].

My herb model contains :

public function herb_forms() { return $this->belongsToMany(HerbForm::class); }

and my herb_forms contains :

public function herbs() { return $this->belongsToMany(Herb::class); } my model herbs_has_form is empty, like this :

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class HerbHasForm extends Model { // }

Once I will understand for this one, I will understand for all others.

Thank you again for your help.

David

Activity icon

Started a new Conversation Display Records From 2 Tables Through A Pivot Table

Hello,

I have two tables :

Herbs :

1 herb1 2 herb2

herb_forms

1 Tea 2 Caps

One herb can have several forms and one forms have several herbs, I created a pivot table :

herbs_have_forms

1 - 1 1- 2 2- 1

I would like to know how can I display the name of herbs and his form please ?

I did all, seed, model, controller... but I don't know how can I create a many to many query ?

Thank you in advance for your help.

May
03
3 weeks ago
Activity icon

Started a new Conversation Laravel 7 Data-table Yajra Not Responsive

Hello everybody,

I'm using Yajra datatable from a weblesson tutorial.

All is working great, but the data-table is NOT responsive.

I included this code :

[code] $('#user_table').DataTable({ responsive: true,[/code]

Like you can on this photo, my table is not responsive :

I searched before posting, but it seems that nobody has this problem ?

Here is my code : [code] How to Delete or Remove Data From Mysql in Laravel 6 using Ajax

    <nav class="navbar navbar-default">
        <div class="container-fluid">
          <!-- Brand and toggle get grouped for better mobile display -->
          <div class="navbar-header" >
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">Accueil</a>
          </div>
      
          <!-- Collect the nav links, forms, and other content for toggling -->
          <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
              <li class="active"><a href="#">Clients <span class="sr-only">(current)</span></a></li>
              <li><a href="#">Abonnements</a></li>
              <li><a href="#">Paiements</a></li>
              <li><a href="#">Articles</a></li>
              <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
                <ul class="dropdown-menu">
                  <li><a href="#">Action</a></li>
                  <li><a href="#">Another action</a></li>
                  <li><a href="#">Something else here</a></li>
                  <li role="separator" class="divider"></li>
                  <li><a href="#">Separated link</a></li>
                  <li role="separator" class="divider"></li>
                  <li><a href="#">One more separated link</a></li>
                </ul>
              </li>
            </ul>
            
            <ul class="nav navbar-nav navbar-right">
              <li><a href="#">Déconnexion</a></li>
              
            </ul>
          </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
      </nav>
    


  <div class="container">    
     <br />
     
     

     
     

     <br />
     <h3 align="center">Gestion des membres de la salle de sport NAJA</h3>
     <br />
     
     
     
     <div align="right">
      <button type="button" name="create_record" id="create_record" class="btn btn-success btn-sm">Ajouter un client</button>
     </div>
     <br />
   <div class="table-responsive">
    <table id="user_table" class="table table-bordered table-striped">
     <thead>
      <tr>
       <th width="35%">First Name</th>
                <th width="35%">Last Name</th>
                <th width="30%">Action</th>
      </tr>
     </thead>
    </table>
   </div>
   <br />
   <br />
  </div>
 </body>
</html>

<div id="formModal" class="modal fade" role="dialog">
 <div class="modal-dialog">
  <div class="modal-content">
   <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Ajouter un nouveau client</h4>
        </div>
        <div class="modal-body">
         <span id="form_result"></span>
         <form method="post" id="sample_form" class="form-horizontal">
          @csrf
          <div class="form-group">
            <label class="control-label col-md-4" >First Name : </label>
            <div class="col-md-8">
             <input type="text" name="first_name" id="first_name" class="form-control" />
            </div>
           </div>
           <div class="form-group">
            <label class="control-label col-md-4">Last Name : </label>
            <div class="col-md-8">
             <input type="text" name="last_name" id="last_name" class="form-control" />
            </div>
           </div>
                <br />
                <div class="form-group" align="center">
                 <input type="hidden" name="action" id="action" value="Add" />
                 <input type="hidden" name="hidden_id" id="hidden_id" />
                 <input type="submit" name="action_button" id="action_button" class="btn btn-warning" value="Add" />
                </div>
         </form>
        </div>
     </div>
    </div>
</div>

<div id="confirmModal" class="modal fade" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h2 class="modal-title">Confirmation</h2>
            </div>
            <div class="modal-body">
                <h4 align="center" style="margin:0;">Voulez-vous vraiment supprimer ce client ?</h4>
            </div>
            <div class="modal-footer">
             <button type="button" name="ok_button" id="ok_button" class="btn btn-danger">OK</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
            </div>
        </div>
    </div>
</div>


<script>
$(document).ready(function(){

 $('#user_table').DataTable({
  responsive: true,
  processing: true,
  serverSide: true,
  
  ajax: {
   url: "{{ route('sample.index') }}",
  },
  columns: [
   {
    data: 'first_name',
    name: 'first_name'
   },
   {
    data: 'last_name',
    name: 'last_name'
   },
   {
    data: 'action',
    name: 'action',
    orderable: false
   }
  ]
 });

 $('#create_record').click(function()
 {
  $('.modal-title').text('Ajouter un nouveau client');
  $('#action_button').val('Add');
  $('#action').val('Add');
  $('#form_result').html('');

  $('#formModal').modal('show');
 });

 $('#sample_form').on('submit', function(event){
  event.preventDefault();
  var action_url = '';

  if($('#action').val() == 'Add')
  {
   action_url = "{{ route('sample.store') }}";
  }

  if($('#action').val() == 'Edit')
  {
   action_url = "{{ route('sample.update') }}";
  }

  $.ajax({
   url: action_url,
   method:"POST",
   data:$(this).serialize(),
   dataType:"json",
   success:function(data)
   {
    var html = '';
    if(data.errors)
    {
     html = '<div class="alert alert-danger">';
     for(var count = 0; count < data.errors.length; count++)
     {
      html += '<p>' + data.errors[count] + '</p>';
     }
     html += '</div>';
    }
    if(data.success)
    {
     html = '<div class="alert alert-success">' + data.success + '</div>';
     $('#sample_form')[0].reset();
     $('#user_table').DataTable().ajax.reload();
    }
    $('#form_result').html(html);
   }
  });
 });

 $(document).on('click', '.edit', function(){
  var id = $(this).attr('id');
  $('#form_result').html('');
  $.ajax({
   url :"sample/"+id+"/edit",
   dataType:"json",
   success:function(data)
   {
    $('#first_name').val(data.result.first_name);
    $('#last_name').val(data.result.last_name);
    $('#hidden_id').val(id);
    $('.modal-title').text('Edit Record');
    $('#action_button').val('Edit');
    $('#action').val('Edit');
    $('#formModal').modal('show');
   }
  })
 });

 var user_id;

 $(document).on('click', '.delete', function(){
  user_id = $(this).attr('id');
  $('#confirmModal').modal('show');
 });

 $('#ok_button').click(function(){
  $.ajax({
   url:"sample/destroy/"+user_id,
   beforeSend:function(){
    $('#ok_button').text('Deleting...');
   },
   success:function(data)
   {
    setTimeout(function(){
     $('#confirmModal').modal('hide');
     $('#user_table').DataTable().ajax.reload();
     alert('Data Deleted');
    }, 2000);
   }
  })
 });

});
</script>

[/code]

Thank you.

Apr
13
1 month ago
Activity icon

Replied to Difference Between Increments, And BigIncrements?

Hi, why have I this as default ? :

$table->id();

Is this the same as $table->bigIncrements('id'); ?

Thank you for your help.

Apr
05
1 month ago
Activity icon

Replied to A Doubt About The Code And Relationship Between Two Tables

Hi Boby,

Thank you for your quick reply.

I can give any name to those functions ?

public function drug_familie() and to public function drugs()

or Laravel has to have the name of the table in singular ?

Thank you again.

PS: I will try and I will let you know.

Apr
04
1 month ago
Activity icon

Started a new Conversation A Doubt About The Code And Relationship Between Two Tables

Hello,

I have two tables :

1- drug (id, name) 2 drug_families (id, name)

One drug has ONE drug_family but a drug_family can have several drugs.

I did this code on my migration :

public function up() { Schema::create('drugs', function (Blueprint $table) { $table->id(); $table->string('name',45); $table->datetime('validated'); $table->timestamps();

        //création d'une clé étrangère, un médicament appartient à une seule famille, une famille
        //peut avoir plusieurs médicaments.
        $table->unsignedBigInteger('drug_family_id');
        $table->foreign('drug_family_id')
        ->references('id')
        ->on('drug_families')
        ->onDelete('cascade')
        ->onUpdate('cascade');
    });
}

I have a doubt about the models :

my drug model :

namespace App;

use Illuminate\Database\Eloquent\Model;

class Drug extends Model { public function drug_familie() { return $this->belongsTo(DrugFamilie::class); } } and my drug_familie model :

namespace App;

use Illuminate\Database\Eloquent\Model;

class DrugFamilie extends Model { public function drugs() { return $this->hasMany(Drug::class); } } Do you think this code is correct ?

Thank you in advance for your help.

Apr
01
1 month ago
Activity icon

Replied to How To Do Insertions Correctly In Laravel 6 ?

Hello, I will be very interesed by a reply too... Thank you in advance.