Heimdall

Heimdall

Member Since 1 Month Ago

Experience Points
710
Total
Experience

4,290 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
0
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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
710 XP
Nov
11
1 week ago
Activity icon

Replied to Connexion Database

ty all for your time, my problem is resolved, i take good model for edit, change membre with user, and rewrite my route

Activity icon

Replied to Connexion Database

@sinnbeck yes i want update the table User but when i was try to put User but dd(membre) display that :

User {#305 #fillable: array:3 [] #hidden: array:2 [] #casts: array:1 [] #connection: null #table: null #primaryKey: "id"

so ...

@cronix ok but i have this error :

The PATCH method is not supported for this route. Supported methods: GET, HEAD, POST.

Activity icon

Replied to Connexion Database

my method store :

public function store()
{
    request() ->validate(
    ["pseudo" => "required"]);

    $pseudo = request("pseudo");
    $email = request("email");
    $password_default ="premiereconnexionspa";
    $membre = new User();
    $membre -> name = $pseudo;
    $membre -> email = $email;
    $membre -> password = Hash::make($password_default);
    $membre -> save();
    
    return back();
}

that work correctly

Activity icon

Replied to Connexion Database

ye my database is config correctly, for store the information i didnt have problem and when i dd(membre) i have that :

Membre {#305 #connection: null #table: null

my route is :

Route::patch('membres', '[email protected]');

i dont need to send id of member on my root, i think because i want recover id auth, for my where

Activity icon

Replied to Connexion Database

up

Activity icon

Started a new Conversation Connexion Database

Hi,

I want update information, but when i test for debug with dd he say no connexion database and table, but how i can i say, use this database ? Because when i created user i use $ member = new User(); but for update i cant use that

my code for update :

public function update(membre $membre,Request $request)
{

        $pseudo = request("pseudo");
        $email = request("email");
        $password = request("password");

        $membre -> name = $pseudo;
        $membre -> email = $email;
        $membre -> password = Hash::make($password);
        $membre -> update(['id'=>3]);   
         dd($membre);
        return redirect('membres/');

}

Ty

Nov
09
1 week ago
Activity icon

Replied to Problem Edit Information

oh yes, that was the problem

Ty :)

Activity icon

Replied to Problem Edit Information

i know i dont save the file, but i just want update my database, i dont understant just why my code on my if is dont executed

ty

Nov
08
1 week ago
Activity icon

Started a new Conversation Problem Edit Information

Hi,

i have a problem for edit my information and idk why:

for store my information i use that :

public function store(Request $request) {

          $nom = request("nom");
          $date = request("datepubli");
          $titre = request("titre");
          $contenu = request("contenu");
       
          $publication = new Publication();
          $publication -> nom = $nom;
          $publication -> date = $date;
          $publication -> titre = $titre;
          $publication -> contenu = $contenu;
        
          if($request->hasfile('imagefirst')){
            $file = $request->file('imagefirst');
            $extension = $file->getClientOriginalExtension();
            $filename = rand(1, 1000000000) . '.' . $extension;
            $GLOBALS["num"] =  $filename;
            $publication -> principalimage =  $GLOBALS["num"];
         
        } else{
         
          $publication->principalimage ='chien.jpg';
        }


         $publication -> save();

that work correctly and for my update i use :

public function update(publication $publication, Request $request,  image $image)
{

  
          $nom = request("nom");
          $titre = request("titre");
          $contenu = request("contenu");
          $datecome = $publication->date;
          $sss = request("imagefirst");

          $publication -> nom = $nom;
           $publication -> date = $datecome;
          $publication -> titre = $titre;
          $publication -> contenu = $contenu;


            if($request->hasfile('imagefirst'))
            {
            $file = $request->file('imagefirst');
            dd($file);
            $extension = $file->getClientOriginalExtension();
            $filename = rand(1, 1000000000) . '.' . $extension;
            $GLOBALS["num"] =  $filename;
            $publication -> principalimage =  $GLOBALS["num"];
         
        } else{
         
          $publication->principalimage ='chien.jpg';
        }

        

$publication -> update();

BUT when i dd( $sss ) that display the picture send by my form, BUT why he dont go on my if ?? because my dd($file display nothink) and my else is exectuted

my form if you want:

@method('PATCH') @csrf Nom du redacteur @error('nom') Remplissez le champs @enderror Titre @error('titre') Remplissez le champs @enderror

  <div class="row">
     <div class="col-lg-4">
        <label>Ajouter une image</label>
        <div class="custom-file">
           <input type="file" class="custom-file-input" id="customFile" name="imagefirst">
           <label class="custom-file-label" for="customFile">Choose file</label>
        </div>
     </div>
     <div class="col-lg-4">
        <label>Ajouter une image</label>
        <div class="custom-file">
           <input type="file" class="custom-file-input" id="customFile" name="imagesecond">
           <label class="custom-file-label" for="customFile">Choose file</label>
        </div>
     </div>
     <div class="col-lg-4">
        <label>Ajouter une image</label>
        <div class="custom-file">
           <input type="file" class="custom-file-input" id="customFile" name="imagelast">
           <label class="custom-file-label" for="customFile">Choose file</label>
        </div>
     </div>
  </div>
     <br>
  <button type="submit" class="btn btn-primary buttonsend" >Ajouter la publication </button>

Ty

Activity icon

Replied to Display Request Eloquent

a little question:

why i cant change my date like that :

public function index()
{

    $chiens = Chien::all();
    $chats = Chat::all();
    $publi = Publication::orderBy('id','DESC') ->skip(0) -> take(3) ->get();
    $formatdatenaissance = date('d-m-Y', strtotime($publi->date));

    
    return view('welcome',['data' => $chiens, 'datas' => $chats, 'datass' => $publi], compact('formatdatenaissance'));
     

}
Activity icon

Replied to Display Request Eloquent

Oh yes, ty :)

Ty for @dd(get_defined_vars()), I did not know :)

Activity icon

Replied to Display Request Eloquent

array:8 [ "__path" => "C:\laragon\www\spa-vesoul\storage\framework\views/97dc9553937cce37b6c47da7ccd3eb0845e87b78.php" "__data" => array:5 [] "obLevel" => 1 "__env" => Factory {#161 } "app" => Application {#2 } "errors" => ViewErrorBag {#282 } "datas" => Collection {#296 } "data" => Collection {#294 } ]

so datass is not send at my view ...

Activity icon

Replied to Display Request Eloquent

you dont like my syntaxe? xD

and yes i have the good number of s

Activity icon

Replied to Display Request Eloquent

when i add dd("hit); at the beggining of my index method, i have

"hit" on my view

i add too dd($publi); and i have the good collection display

Activity icon

Replied to Display Request Eloquent

yes, i have others request, who work correctly :

public function index()
{
    $chiens = Chien::all();
    $chats = Chat::all();
    $publi = Publication::orderBy('id','DESC') ->skip(0) -> take(2) ->get();
    
    return view('welcome',['data' => $chiens], ['datas' => $chats], ['datass' => $publi]);
     

}

just publi doesn't work

Activity icon

Started a new Conversation Display Request Eloquent

Hi

I want display my collection on my view but i have one error:

public function index()
{

    $publi = Publication::orderBy('id','DESC') ->skip(0) -> take(2) ->get();
    return view('welcome',['datass' => $publi]);
     

}

and on my view:

@foreach($datass as $publi)

{{ $publi-> nom}}

{{ $publi-> titre}}

@endforeach

and my error is:

Undefined variable: datass (View: C:\laragon\www\spa-vesoul\resources\views\welcome.blade.php)

Ty

Nov
03
2 weeks ago
Activity icon

Replied to Multi Table

hum ye, on my table image i save the id of dog when i add image of this dog

Activity icon

Started a new Conversation Multi Table

Hi,

I have one problem when i want display the information on database on my view.

I have 2 table, one table with information like name etc and on other one with the picture

However, i want display the good information with the good picture on my webpage but how ? i know how do that when i recover the ID, like for edit information , but on this webpage i want display all the dog with a carousel, so idk how i can make jointure for that. When i edit one dog i do that :

public function show($chien)
{
    $chien = Chien::find($chien);
    $image = Image::where('id_chien', '=', $chien->id) ->get();
    $formatdatenaissance = date('d-m-Y', strtotime($chien->naissance));
    $formatdatearrive = date('d-m-Y', strtotime($chien->arrive));
    return view('chiens.show', compact('chien', 'image','formatdatenaissance','formatdatearrive'));
}

but that work only when i want see the information on one dog

Oct
18
1 month ago
Activity icon

Replied to Update BDD

ty man ;)

Activity icon

Replied to Update BDD

yes ty i success this morning, i was tired yesterday lol

i have just one question, i have 3 images with the same id chiens, so when i want edit all pictures, the function first give me juste the first id, so for that i do that :

$images = Image::where('id_chien', '=', $chien->id) ->first();

$image = $images->id;

$imageplace2 = $image +1;

$imageplace3 = $image +2;

$images2 = Image::where('id', '=', $imageplace2) ->first();

$images3 = Image::where('id', '=', $imageplace3) ->first();

that work correctly, but maybe there is another way to do it

Ty for your time and your tips and sorry for my english i m french student ^^

Oct
17
1 month ago
Activity icon

Replied to Update BDD

other one for help me ?

        $image = Image::where('id_chien', '=', $chien->id) ->get();
        $image = $image->id;

Why that dont work, i have this error :

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

@sinnbeck

Activity icon

Replied to Update BDD

when i display my picture i do like that :

public function show($chien)
{
    $chien = Chien::find($chien);
    $image = Image::where('id_chien', '=', $chien->id) ->get();
    $formatdatenaissance = date('d-m-Y', strtotime($chien->naissance));
    $formatdatearrive = date('d-m-Y', strtotime($chien->arrive));
    return view('chiens.show', compact('chien', 'image','formatdatenaissance','formatdatearrive'));
}

On my view

    <div class="row">
    @foreach ($image as $object)
    <div class="col-lg-4">
    <div><img class="foodimg" src="/images/{{ $object->image }}" width="200px" height="200px"></div><br>
    </div>
        @endforeach
        </div>
Activity icon

Replied to Update BDD

my database is like that :

   Schema::create('images', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->integer('id_publication');
        $table->integer('id_chien');
        $table->mediumText('image')->nullable();
        $table->timestamps();
    });

so i need to recover "id" no ?

Activity icon

Replied to Update BDD

i try that :

$image = Image::where('id_chien', '=', $chien->id) ->get();

but that dont give me just the id, and i try that :

$image = image[0]->id;

but i have a error so idk

Activity icon

Replied to Update BDD

ye but i dont need to seem to load the image from the database, i just want update, so i crush the next image and i change with the new image .. no ? else, i need to change or add what for my code to work ? for seem to load the image from the database i just need to add value="{{ image -> image }} "?

EDIT: sorry i see your code after my post, i try that

Activity icon

Replied to Update BDD

my method store work correctly with this code :

        $idpublication = 0;
        $id_chien = $chien->id;

    $image = new Image();
    $image -> id_publication = $idpublication;
    $image -> id_chien = $id_chien;

    if($request->hasfile('imagefirst')){
        $file = $request->file('imagefirst');
        $extension = $file->getClientOriginalExtension();
        $filename = rand(1, 1000000000) . '.' . $extension;
        $file->move('images/', $filename);
      $image-> image = $filename;
     
    }

    $image -> save();

so i really dont know with my update dont work

Activity icon

Replied to Update BDD

@method('PATCH') @csrf
<div class="row">
    <div class="col-lg-6">

            <label>Nom du chien</label>
            <input type="text" class="form-control @error('nom') is-invalid @enderror" name="nom" placeholder="nom" value=" {{old('nom') ?? $chien-> name}}" }}>
            @error('nom')
            <div class="invalid-feedback">
               Remplissez le champs
            </div>
            @enderror

    </div>

    <div class="col-lg-6">

    </div>
</div>



  <br><br>
  <label>Race du chien</label>
  <input type="text" class="form-control @error('race') is-invalid @enderror" name="race" placeholder="race" value=" {{old('race') ?? $chien-> race}}">
  @error('race')
  <div class="invalid-feedback">
     Remplissez le champs
  </div>
  @enderror
  <br><br>



  <div class="row">
      <div class="col-lg-4">

            <label>Entente avec les chiens</label>
            <input type="text" class="form-control @error('ententechien') is-invalid @enderror" name="ententechien" placeholder="ententechien" value=" {{old('Ententechien') ?? $chien-> Ententechien}}">
            @error('ententechien')
            <div class="invalid-feedback">
               Remplissez le champs
            </div>
            @enderror
      </div>


      <div class="col-lg-4">
            <label>Entente avec les chats</label>
            <input type="text" class="form-control @error('ententechat') is-invalid @enderror" name="ententechat" placeholder="ententechat" value=" {{old('Ententechat') ?? $chien-> Ententechat}}">
            @error('ententechat')
            <div class="invalid-feedback">
               Remplissez le champs
            </div>
            @enderror
      </div>


      <div class="col-lg-4">
            <label>Caractère du chien</label>
            <input type="text" class="form-control @error('caractere') is-invalid @enderror" name="caractere" placeholder="caractere" value=" {{old('caractere') ?? $chien-> caractere}}">
            @error('caractere')
            <div class="invalid-feedback">
               Remplissez le champs
            </div>
            @enderror
      </div>


  </div>

  <br><br>
        <div class="col-lg-4">
              <label>Ajouter une image</label>
              <div class="custom-file">
                    <input type="file" class="custom-file-input" id="customFile" name="imagefirst">
                    <label class="custom-file-label" for="customFile">Choose file</label>
                  </div>
           </div>

      <div class="col-lg-4">
           <label>Ajouter une image</label>
           <div class="custom-file">
                 <input type="file" class="custom-file-input" id="customFile" name="imagesecond">
                 <label class="custom-file-label" for="customFile">Choose file</label>
               </div>
      </div>

      <div class="col-lg-4">
            <label>Ajouter une image</label>
            <div class="custom-file">
                  <input type="file" class="custom-file-input" id="customFile" name="imagelast">
                  <label class="custom-file-label" for="customFile">Choose file</label>
                </div>
        </div>
  </div>

  <br>
<br>
  <button type="submit" class="btn btn-primary buttonsend">Ajouter le chien</button>

the form does no display but he is before de @method patch

and when i put dd($image) before the update :

Image {#287 #table: "images" #fillable: array:3 [] #connection: null #primaryKey: "id" #keyType: "int" +incrementing: true #with: [] #withCount: [] #perPage: 15 +exists: false +wasRecentlyCreated: false #attributes: array:3 [] #original: [] #changes: [] #casts: [] #dates: [] #dateFormat: null #appends: [] #dispatchesEvents: [] #observables: [] #relations: [] #touches: [] +timestamps: true #hidden: [] #visible: [] #guarded: array:1 [] }

Activity icon

Replied to Update BDD

ty for your response

and ye i include that

Activity icon

Replied to Update BDD

up

Activity icon

Started a new Conversation Update BDD

Hello,

i have little problem with update on my BDD: my problem is :

i have 2 table : 1 table = chiens and 1 table images

I want edit information on my form, so for edit the name etc i use my table chiens :

public function update(chien $chien, Request $request, image $image)
{


          $nom = request("nom");
          $race = request("race");
          $ententechien = request("ententechien");
          $ententechat = request("ententechat");
          $caractere = request("caractere");
          $datecome = request("datecome");
          
         
          $chien -> name = $nom;
          $chien -> race = $race;
          $chien -> Ententechien = $ententechien;
          $chien -> Ententechat = $ententechat;
          $chien -> caractere = $caractere;
          $chien -> update();   

and on this form i can change the image to, so i use this code for update my table image:

public function update(chien $chien, Request $request, image $image) {

          $nom = request("nom");
          $race = request("race");
          $ententechien = request("ententechien");
          $ententechat = request("ententechat");
          $caractere = request("caractere");
          $datecome = request("datecome");
          
         
          $chien -> name = $nom;
          $chien -> race = $race;
          $chien -> Ententechien = $ententechien;
          $chien -> Ententechat = $ententechat;
          $chien -> caractere = $caractere;

          $chien -> update();   
        
   


        $idpublication = 0;
        $id_chien = $chien->id;
          
          if($request->hasfile('imagefirst'))
          {
            $image -> id_publication = $idpublication;
            $image -> id_chien = $id_chien;
            $file = $request->file('imagefirst');
            $extension = $file->getClientOriginalExtension();
            $filename = time() . '.' . $extension;
            $file->move('images/', $filename);
            $image-> image = $filename;
            dd($request->file('imagefirst'));
        } 

        $image -> update();   
    
}

my first update on table chiens work correctly, but my second update with the table image dont work and i dont know why

If you can help me :)

Ty

Oct
14
1 month ago
Activity icon

Replied to Laravel Input Old Date

ok ty for your time and sorry for my bad english, i m french student and i start to learn Laravel

Activity icon

Replied to Laravel Input Old Date

and i cant change the default format on database ?

Activity icon

Replied to Laravel Input Old Date

ok.. so you dont know why the date after Carbon::parse is Y-m-d ? and not d-m-Y ?

Activity icon

Replied to Laravel Input Old Date

yes sorry, but this code : $chien->naissance = Carbon\Carbon::parse($naissance); dont choose my format for the date ?

dd( $chien-> naissance = Carbon::parse($naissance));

and the response is Carbon @1570060800 {#328 date: 2019-10-03 00:00:00.0 UTC (+00:00) }

Activity icon

Replied to Laravel Input Old Date

namespace App\Http\Controllers; use Carbon\Carbon; use App\Chien;

i add Carbon\Carbon; but i have this error now :

Class 'Carbon\Carbon\Carbon' not found

Activity icon

Replied to Laravel Input Old Date

yes but dd($chien->naissance->format('d-m-Y')); is on Controller if i want update my database i needto change my code but my model for add data is:

$naissance = request("naissance"); $chien -> naissance = $naissance; $chien -> update();

but how add format('d-m-Y') ? if i use that : $chien -> naissance = $naissance -> format('d-m-Y') ; i have the next error :

Call to a member function format() on string

Activity icon

Replied to Laravel Input Old Date

ok ty so now the response is good :

"25-10-2019"

Activity icon

Replied to Laravel Input Old Date

dd($chien->naissance); for that the response is 2019/10/14

and for that dd($chien->naissance->format('d-m-Y')); i have one error : Call to a member function format() on string

and no i dont use JS

Activity icon

Replied to Laravel Input Old Date

Yes i think is that the problem, my database is Y-m-d and my input is d-m-Y but i try to use your code but that change nothing ;/

Activity icon

Replied to Laravel Input Old Date

Ye i change like you, old('naissance', $chien->naissance) but that dont work, if i edit my profil, this input dont recover the information on my database only because this type of input is "date"... Other input recover good information on my database

Activity icon

Replied to Laravel Input Old Date

yes idk why i use nom ^^ but that work correctly, but for this input with type= "date" that dont work : {{old('naissance' ) that work correctly but that ?? $chien-> naissance}} dont work only when the input is date

<input type="date" class="form-control @error('naissance') is-invalid @enderror" name="naissance" placeholder="naissance" value=" {{old('naissance' ) ?? $chien-> naissance}}" }}>

Activity icon

Started a new Conversation Laravel Input Old Date

Hi,

I have problem with my input for recover the next data when i edit a form

When its not type="date" i use that :

value=" {{old('nom') ?? $chien-> name}}" }}>

but when its type date, that didn't work, so what its the problem ?

Thanks

Oct
13
1 month ago
Activity icon

Started a new Conversation Update Image With Form

Hello

I need your help today, i want update i form with picture on my database but idk my code didnt work ^^ If you can help me :

public function store(Request $request) {

          $nom = request("nom");
          $naissance = request("naissance");
          $couleur = request("couleur");
          $caractere = request("caractere");
          $datecome = request("datecome");

       
          $chat = new Chat();
          $chat -> name = $nom;
          $chat -> naissance = $naissance;
          $chat -> couleur = $couleur;
          $chat -> caractere = $caractere;
          $chat -> arrive = $datecome;
       

          if($request->hasfile('image')){
              $file = $request->file('image');
              $extension = $file->getClientOriginalExtension();
              $filename = time() . '.' . $extension;
              $file->move('uploads/chat/', $filename);
              $chat-> image = $filename;
           
          } else{
              return $request;
              $chat->image ='';
          }
         $chat -> save();
    
        return view('/chats')->with('chats',$chat);
}

Thank guys