Morbakos

Morbakos

Member Since 6 Days Ago

Experience Points 270
Experience Level 1

4,730 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 Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

13 Jun
5 days ago

Morbakos left a reply on Function Update Doens't Work

Actually, I found the problem. It seems that it doesn't come from the repository but from my form. Thank you for your help anyway, especially you @na.

Morbakos left a reply on Function Update Doens't Work

@NAKOV - So, I got this when I do the dd in the getById function

Mission {#309 ▼
  +table: "missions"
  +primaryKey: "id_mission"
  +timestamps: false
  #fillable: array:13 [▶]
  #connection: "mysql"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: true
  +wasRecentlyCreated: false
  #attributes: array:14 [▼
    "id_mission" => 1
    "nom_mission" => "Find and Kill"
    "auteur_mission" => "Morbakos"
    "map_mission" => "Tanoa"
    "composante_mission" => "Charlie"
    "nombre_slots_mission" => 30
    "correction_mission" => null
    "zeus_mission" => "Non"
    "briefing_mission" => """
      Depuis plus d’une heure, nous avons perdu le contact avec la Base d’opération Avancée (BOA ou FOB) “Sabre” sur l’île de Tanoa. Nous craignons que quelqu’un cher ▶
      Votre force d’intervention est la plus proche, embarquée à bord de l’USS Nimitz. <br>Présentez-vous sur le pont d’envol, embarquez avec vos hommes à bord de Fox ▶
      """
    "hostile_mission" => "Inconnu"
    "duree_estimee_mission" => 3
    "statut_mission" => "Jouable"
    "nombre_jouer_mission" => "1"
    "type_mission" => "Offensive"
  ]
  #original: array:14 [▶]
  #casts: []
  #dates: []
  #dateFormat: null
  #appends: []
  #events: []
  #observables: []
  #relations: []
  #touches: []
  #hidden: []
  #visible: []
  #guarded: array:1 [▶]
}

So I have the data in the attributes array

Morbakos left a reply on Function Update Doens't Work

@NAKOV - I am always referred to the update form, without the display of the dd

Morbakos left a reply on Function Update Doens't Work

@NAKOV - Where should I try it ? In the ResourceRepository ?

Morbakos left a reply on Function Update Doens't Work

@NAKOV - the dd showed this:

Mission {#272 ▼
  +table: "missions"
  +primaryKey: "id_mission"
  +timestamps: false
  #fillable: array:13 [▼
    0 => "nom_mission"
    1 => "auteur_mission"
    2 => "map_mission"
    3 => "composante_mission"
    4 => "nombre_slots_mission"
    5 => "correction_mission"
    6 => "zeus_mission"
    7 => "briefing_mission"
    8 => "hostile_mission"
    9 => "duree_estimee_mission"
    10 => "statut_mission"
    11 => "nombre_jouer_mission"
    12 => "type_mission"
  ]
  #connection: null
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: false
  +wasRecentlyCreated: false
  #attributes: []
  #original: []
  #casts: []
  #dates: []
  #dateFormat: null
  #appends: []
  #events: []
  #observables: []
  #relations: []
  #touches: []
  #hidden: []
  #visible: []
  #guarded: array:1 [▶]
}

So I guess, it's ok.

Sorry, I pasted the wrong code, here's the right code (without the dd):

<?php

namespace App\Repositories;

use App\Mission;

class MissionRepository extends ResourceRepository
{

    public function __construct(Mission $mission)
    {
        $this->model = $mission;
    }

}

Morbakos left a reply on Function Update Doens't Work

@NAKOV - When I try your code, I got this:

[!] Aliasing 'Mission' to 'App\Mission' for this Tinker session.
=> true
``` and it work.

As for the manufacturer, it is in the MissionRepository, whose code is as follows:

Morbakos left a reply on Function Update Doens't Work

Here's the code of my ResourceRepository:

<?php

namespace App\Repositories;

abstract class ResourceRepository
{

    protected $model;

    public function getPaginate($n)
    {
        return $this->model->paginate($n);
    }

    public function store(array $inputs)
    {
        return $this->model->create($inputs);
    }

    public function getById($id)
    {
        return $this->model->findOrFail($id);
    }

    public function update($id, array $inputs)
    {
        $this->getById($id)->update($inputs);
    }

    public function destroy($id)
    {
        $this->getById($id)->delete();
    }

}

Morbakos left a reply on Function Update Doens't Work

@MUNAZZIL - The id is required, because I use it in my Repository (see below)

@nakov In reality, my MissionRepository inherits ResourceRepository, of which here is the code:

public function update($id, Array $inputs)
    {
        $this->getById($id)->update($inputs);
    }

Morbakos started a new conversation Function Update Doens't Work

Hi there,

I have an issue, because when I try to update data with a resource controller, the data still unchanged. Here's my function:

public function update(MissionUpdateRequest $request, $id)
    {
        $this->missionRepository->update($id, $request->all());
        
        return redirect('missions.index')->withOk("La mission " . $request->input('nom_mission) . " a été modifié.");
    }

Morbakos left a reply on Problem With Method Not Allowed Exception

It looks like, thanks for your help !

12 Jun
6 days ago

Morbakos left a reply on Problem With Method Not Allowed Exception

So, I solve the problem, but now he problem is that data are not updated ..

Morbakos left a reply on Problem With Method Not Allowed Exception

Now, I have this issue: `ReflectionException

Class App\Htpp\Requests\MissionUpdateRequest does not exist` but the file exist

Morbakos left a reply on Problem With Method Not Allowed Exception

So, I got the id in comment, like this:

<!-- 1 -->
<form method="POST" action="http://gie/missions" accept-charset="UTF-8" class="form-horizontal panel">
<input name="_method" type="hidden" value="PUT">

Morbakos left a reply on Problem With Method Not Allowed Exception

So, now I have this in the source code, but it's the same result as before

<form method="POST" action="http://gie/missions" accept-charset="UTF-8" class="form-horizontal panel"><input name="_method" type="hidden" value="PUT">

Morbakos left a reply on Problem With Method Not Allowed Exception

@SNAPEY - Yes, I didn't change anything. My route is like: PUT/PATCH /missions/{mission} missions.update GET/HEAD /missions/{mission}/edit missions.edit

Morbakos left a reply on Problem With Method Not Allowed Exception

I got this in the source code :

<form method="POST" action="http://gie/missions/1/edit" accept-charset="UTF-8" http://gie/missions/1 class="form-horizontal panel"> <input name="_method" type="hidden" value="PUT">

Morbakos left a reply on Problem With Method Not Allowed Exception

@SNAPEY - Yes, $mission->id_missions is correct

11 Jun
1 week ago

Morbakos started a new conversation Problem With Method Not Allowed Exception

Hi,

I have a problem with the update method. When I submit the form, I have the error MethodNotAllowedHttpException in RouteCollection.php line 251.

Here's my form:

{!! Form::model($mission, [route('missions.update', $mission->id_missions), 'method' => 'PUT', 'class' => 'form-horizontal panel']) !!}
   {!! Form::token(); !!} 
                    <div class="form-group {!! $errors->has('nom_mission') ? 'has-error' : '' !!}">
                    <fieldset style="display:inline-block;">
                        <legend>Ajouter une mission :</legend>
                       Nom & auteur(s) :&nbsp&nbsp&nbsp&nbsp {!! Form::text('nom_mission', null, ['class' => 'form-control', 'placeholder' => 'Nom de la mission']) !!}&nbsp&nbsp&nbsp&nbsp
                        {!! Form::text('auteur_mission', null, ['class' => 'form-control', 'placeholder' => 'Auteur(s) de la mission']) !!}<br/><br/>
                        Map:&nbsp&nbsp&nbsp&nbsp {!! Form::select('map_mission', array(
                        'Map d\'Arma3' => array('Altis' => 'Altis','Stratis' => 'Stratis', 'Tanoa' => 'Tanoa', 'Malden2035' => 'Malden 2035'),
                        'Map de CUP' => array('Bukovina' => 'Bukovina', 'Bystrica' => 'Bystrica', 'Chernarus (Autumn)' => 'Chernarus (Autumn)', 'Chernarus (Summer)' => 'Chernarus (Summer)', 'Chernarus (Winter)' => 'Chernarus (Winter)', 'Desert' => 'Desert','Desert Island' => 'Desert Island','Everon' => 'Everon','Kolgujev' => 'Kolgujev','Malden' => 'Malden','Nogova' => 'Nogova','Porto' => 'Porto','Proving Grounds' => 'Proving Grounds','Rahmadi' => 'Rahmadi','Sahrani' => 'Sahrani','Shapur' => 'Shapur','Southern Sahrani' => 'Southern Sahrani','Takistan' => 'Takistan','Takistan_mountains' => 'Takistan Mountains','United_sahrani' => 'United Sahrani','Utes' => 'Utes','Zargabad' => 'Zargabad'),
                        ));!!}<br/><br/>
                        Nbr Slots :&nbsp&nbsp&nbsp&nbsp{!! Form::text('nombre_slots_mission', null, ['class' => 'form-control', 'placeholder' => 'Nombre de slots'])!!}<br/><br/>
                        Correction :&nbsp&nbsp&nbsp&nbsp{!! Form::text('correction_mission', null, ['class' => 'form-control', 'placeholder' => 'Correction nécessaire'])!!}<br/><br/>
                        Zeus nécessaire ?&nbsp&nbsp&nbsp&nbspOui {!! Form::radio('zeus_mission', 'Oui')!!} - Non
                        {!! Form::radio('zeus_mission', 'Non', true)!!}<br/><br/>
                        Briefing :&nbsp&nbsp&nbsp&nbsp{!! Form::textarea('briefing_mission', null, ['class' => 'form-control', 'placeholder' => 'Briefing à saisir']) !!}<br/><br/>
                        Ennemis :&nbsp&nbsp&nbsp&nbsp{!! Form::text('hostile_mission', null, ['class' => 'form-control', 'placeholder' => 'Hostile de la mission']) !!}<br/><br/>
                        Durée estimée :&nbsp&nbsp&nbsp&nbsp{!! Form::text('duree_estimee_mission', null, ['class' => 'form-control', 'placeholder' => 'Durée estimée']) !!}<br/><br/>
                        Statut de la mission :&nbsp&nbsp&nbsp&nbsp{!! Form::select('statut_mission', array(
                        'Statut actuel :' => array('A tester' => 'A tester','Jouable' => 'Jouable', 'A corriger' => 'A corriger'),
                        ));!!}<br/><br/>
                        Nombre de fois jouer :&nbsp&nbsp&nbsp&nbsp{!! Form::text('nombre_jouer_mission', null, ['class' => 'form-control', 'placeholder' => 'Nombre de fois jouer']) !!}<br/><br/>
                        Type de mission :&nbsp&nbsp&nbsp&nbsp{!! Form::select('type_mission', array(
                        'Type disponible :' => array('Offensive' => 'Offensive','Defensive' => 'Defensive', 'PvP' => 'PvP'),
                        ));!!}<br/><br/>
                        {!! $errors->first('nom_mission', '<small class="help-block">:message</small>') !!}<br/><br/>
                        {!! Form::submit('Envoyer', ['class' => 'btn btn-primary pull-right']) !!}
                        </fieldset>
                    {!! Form::close() !!}

My controller:

public function update(MissionUpdateRequest $request, $id)
    {
        $this->missionRepository->update($id, $request->all());
        
        return redirect('missions.index')->withOk("L'utilisateur " . $request->input('name') . " a été modifié.");
    }

My routes:

Route::resource('missions', 'MissionController', ['except' => 'show', 'edit', 'update', 'destroy' ]);

Please help, I need it ASAP ...