Meaulnes

Meaulnes

Member Since 1 Month Ago

Experience Points
600
Total
Experience

4,400 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 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
600 XP
Oct
23
1 day ago
Activity icon

Replied to How To Implement Real Time Validation With Livewire 2

Thank you for your answer. I tried this also, but my trouble was coming from elsewhere. I used an input-group component but forgot to change the name of the props e.g. 'name' instead of 'malt.name' thus the error message was not displayed.

Activity icon

Started a new Conversation How To Implement Real Time Validation With Livewire 2

Before I applied new livewire V2 programming style I had a form that was wired to a Model's individual properties. To trigger the real time validation for fields, I used this in the component (e.g. name property):

public function updatedName(){
      $this->validate(['name' =>'required|max:127']);
}

name being a property of a Model named Malt. My question is: how to modify this updatedName() function in the case I use the Malt model in the component instead of individual properties?

I already understood that I should rename the function to updatedMaltName, thus I tried this.

public function updatedMaltName(){ 
  $this->validate(['name' =>'required|max:127']);
}

but it doesn't work. Instead it display an error "The name field is required" as soon as I type a char in the field (which is the opposite of what should happen), and never hide this error even if I empty the field.

I also tried this

public function updatedMaltName(){
      $this->validate(['malt.name' =>'required|max:127']);
   }

but this doesn't work at all.

Oct
12
1 week ago
Activity icon

Replied to Laravel SQLSTATE[22007]: Invalid Datetime Format: 1366

I finally found an explanation. It has nothing to do with time. Product::create doesn't return an ID but a Product thus I had to change

$product_id=Product::create..... 

with

$product=Product::create.... 

and below use

$this->validatedData['product_id']=$product->id;
Activity icon

Started a new Conversation Laravel SQLSTATE[22007]: Invalid Datetime Format: 1366

I try to save some models in my database and I meet a error I cannot understand regarding datetime format

Here are the migrations

class CreateTableProducts extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->id();
            $table->string('category',25);
            $table->string('name',127);
            $table->timestamps();
        });
    }

class CreateTableMalts extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('malts', function (Blueprint $table) {
            $table->id();
            $table->foreignId('product_id')->constrained()->cascadeOnDelete();
            $table->string('name',127);
            $table->string('producter',50)->nullable();
            $table->float('max_yield');
            $table->float('ebc');
            $table->float('kolbach_min')->nullable();
            $table->float('kolbach_max')->nullable();

            $table->timestamps();
        });
    }

Here is the store function of my livewire component Malt.Create

    public function store(){

        //dd($this);
        $this->validatedData=$this->validate([
            'name'=>'required|max:127',
            'max_yield'=> 'required|numeric|max:99',
            'ebc'=>'required|numeric',
            'kolbach_min'=>'numeric|max:100',
            'kolbach_min'=>'numeric|max:100'

        ]);
        
        DB::transaction(function () {
            //we create a product associated with this malt
            $product_id=Product::create([
                'category'=>'malt',
                'name'=>$this->validatedData['name']
            ]);
            $this->validatedData['product_id']=$product_id;
        
            Malt::create($this->validatedData);
        
        });
    }

When calling the store function from the component, I get the following message

Illuminate\Database\QueryException SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '{"category":"malt","name":"Test","updated_at":"2020-10-12T14:15:13.000000Z","created_at":"2020-10-12T14:15:13.000000Z","id":4}' for column easybeer.malts.product_id at row 1 (SQL: insert into malts (name, max_yield, ebc, kolbach_min, product_id, updated_at, created_at) values (Test, 80, 8, 35, {"category":"malt","name":"Test","updated_at":"2020-10-12T14:15:13.000000Z","created_at":"2020-10-12T14:15:13.000000Z","id":4}, 2020-10-12 14:15:13, 2020-10-12 14:15:13)) http://localhost:8000/livewire/message/malt.create

I suspect the 00000Z at the end of the timestamps but I wonder why it is present

Oct
06
2 weeks ago
Activity icon

Replied to Why This Strange Behaviour With Livewire And Pagination And How To Fix It?

I eventually got some help on stackoverflow. There was two reasons why this could not work properly:

First I should have used the WithPagination trait of Livewire. Not using it, forced me to use a toArray() and completely change the treatment into the view 's loop and adapt the rendering of the pagination links.

Second I should have not used a public property for $posts. This triggered a complaint from Livewire as what type a public property can accept., complaint that disappeared after using toArray(). Normally the loop in the view is not based on an array and is a foreach ($posts as $post) allowing to access properties more easily with statements such as $post->title

Activity icon

Started a new Conversation Why This Strange Behaviour With Livewire And Pagination And How To Fix It?

I started with Laravel 8 and livewire a few days ago. I still have a lot to discover but I am on my way.

Lastly, I encountered a behaviour I have trouble understanding.

My goal

I want to create a page to CRUD posts. What I want is to have a post list that is paginated displayed at the bottom of the page, a button to create a new post and the possibility to click a button on each post line to edit the post. I also want the editor of the post displayed at the top of the page while the list is hidden (but this last possibility is not absolutely necessary).

I could manage to have this working as long as the post list is not paginated but not with pagination.

To do this I use a liveewire component whose code is herebelow:

Component's code in app/Http/livewire/posts/Posts.php

<?php
namespace App\Http\Livewire\Posts;
use App\Models\Post;
use Livewire\Component;
class Posts extends Component
{
public $posts;
public $links;
public $post_id,$title, $abstract, $body,$category,$diaporama_dir,
       $beg_date,$end_date,$close_date,$receive_registration,
       $sticky,$user_id,$inscription_directive;   
/**
 * The attributes that are mass assignable.
 *
 * @var array
 */
public  function render()
{   
    $this->mode='list';
    $this->posts=Post::select('id','title')->orderBy('created_at','DESC')->paginate(15)->toArray();
    $this->links=$this->posts['links'];
    //dd($this->links);
    $this->user_id=auth()->user()->id;
    return view('livewire.posts.posts');
}
public function donothing(){

}
/*
 * The attributes that are mass assignable.
 *
 * @var array
 */
public function resetInputFields(){
    $this->title = '';
    $this->body = '';
    $this->title='';
    $this->abstract='';
    $this->body='';
    $this->category='';
    $this->diaporama_dir='';  
    $this->beg_date='';
    $this->end_date='';
    $this->close_date='';
    $this->receive_registration='';
    $this->sticky='';
    
    $this->inscription_directive='';
}
/**
 * The attributes that are mass assignable.
 *
 * @var array
 */
public function store()
{
    
    $validatedData = $this->validate([
        'title' => 'required',
        'body' => 'required',
        'abstract'=>'required',
        'category'=>'',
        'diaporama_dir'=>'',
        'beg_date'=>'sometimes',
        'end_date'=>'sometimes',
        'close_date'=>'sometimes',
        'receive_registration'=>'',
        'sticky'=>'',
        'user_id'=>'required',
        'inscription_directive'=>''
    ]);
    Post::create($validatedData);
    session()->flash('message', 'Bravo ! Votre article a été enregistré.');
   // $this->resetInputFields(); //user may want to keep the input stable
}
/**
 * The attributes that are mass assignable.
 *
 * @var array
 */
public function edit($id)
{
    $post = Post::findOrFail($id);
    $this->post_id = $id;
    $this->title = $post->title;
    $this->abstract=$post->abstract;
    $this->body=$post->body;
    $this->category=$post->category;
    $this->diaporama_dir=$post->diaporama_dir;  
    $this->beg_date=$post->beg_date;
    $this->end_date=$post->end_date;
    $this->close_date=$post->close_date;
    $this->receive_registration=$post->receive_registration;
    $this->sticky=$post->sticky;
    $this->inscription_directive=$post->inscription_directive;

    $this->dispatchBrowserEvent('notify','je passe en mode edit');//to switch browser page to edit mode
}


    /**
 * The attributes that are mass assignable.
 *
 * @var array
 */
public function update()
{
    $validatedData = $this->validate([
        'title' => 'required',
        'body' => 'required',
        'abstract'=>'required',
        'category'=>'',
        'diaporama_dir'=>'',
        'beg_date'=>'sometimes',
        'end_date'=>'sometimes',
        'close_date'=>'sometimes',
        'receive_registration'=>'',
        'sticky'=>'',
        'user_id'=>'required',
        'inscription_directive'=>''
    ]);

    $post = Post::find($this->post_id);
    $post->update([
        'title' => $this->title,
        'body'=> $this->body,
        'abstract'=> $this->abstract,
        'category'=> $this->category,
        'diaporama_dir'=>$this->diaporama_dir,
        'beg_date'=>$this->beg_date,
        'end_date'=>$this->end_date,
        'close_date'=>$this->close_date,
        'receive_registration'=>$this->receive_registration,
        'sticky'=>$this->sticky,
        'user_id'=>$this->user_id,
        'inscription_directive'=>$this->inscription_directive
    ]);
  
    session()->flash('message', "Bravo ! L'article a été mis à jour.");

   // $this->resetInputFields();//user may like to keep the input fields stable

}

} and views are these:

View 1 : the main page in resources/views/livewire/posts/posts.blade.php

<div class="container m-auto  w-10/12">
<div x-data="{ mode: 'list' }">
    @if (session()->has('message'))
        <div class="bg-green-200 p-4 w-full my-8 text-xl text-orange-500">
            {{ session('message') }}
        </div>
    @endif
    <div x-on:notify.window="mode = 'update'">
        <div x-show="mode==='update'">
            @include('livewire.posts.update')
        </div>

        <div x-show="mode === 'edit'">
            @include('livewire.posts.create')
        </div>
    </div>

   {{-- <div x-show="mode === 'list'" class="">--}} 
       <div>
        <div>
            <button x-on:click="mode = 'edit'" class="bg-red-400 px-2 py-1 border rounded-lg mt-2">Nouvel
                article</button>

        </div>
        <table class=" bg-green-400 w-full table table-bordered mt-5 ">
            <thead>
                <tr class="bg-red-50 mb-2">
                    <th>Id.</th>
                    <th>Titre</th>
                    <th width="150px">Action</th>
                </tr>
            </thead>
            <tbody>

                @for ($i = 0; $i < $posts['per_page']; $i++)
                    <tr class="bg-red-400 mb-2 p-2 space-y-2 border-8 border-red-50 ">
                        <td>{{ $posts['data'][$i]['id'] }}</td>
                        <td>{{ $posts['data'][$i]['title'] }}</td>
                        <td>{{--les actions--}}
                            <button wire:click="edit({{ $posts['data'][$i]['id'] }})"
                                class="btn btn-primary btn-sm">Edit</button>
                            {{-- <button wire:click="delete({{ $post->id }})"
                                class="btn btn-danger btn-sm">Delete</button>--}}
                        </td>
                    </tr>
                @endfor
            </tbody>
        </table>
        <div class="flex flex-row mt-2">
            @for ($i = 0; $i < count($links); $i++)
                <div class="flex p-2 mr-2 border w-max-content">
                     <a href="{{$links[$i]['url'] }}">{{$links[$i]['label']}}</a>

                </div>
            @endfor
        </div>
    </div>
</div>

2- create include in resources/views/livewire/posts/create.blade.php

<div class="container bg-green-500 p-4">
    <form>
        This is the create form
        <input type="hidden" name="user_id" wire:model="user_id" >
        <div class="flex flex-col md:flex-row" >
        <div class=" mt-2 flex flex-col w-max-content">
            <label for="category">Catégorie:</label>
            <select class="" name="category" id="category" wire:model="category">
                <option value="Sans">Sans</option>
                <option value="Annoncement">Annonce d'un événement</option>
            </select>
            @error('category') <span class="text-danger">{{ $message }}</span>@enderror
        </div>
        <div class=" mt-2 flex flex-col flex-auto ml-4">
            <label for="title">Title:</label>
            <input type="text" class="form-control" name="title" id="title" placeholder="Saisissez un titre"
                wire:model="title" value="">
            @error('title') <span class="text-danger">{{ $message }}</span>@enderror
        </div>

    </div>
    <div class="flex flex-col md:flex-row" >
        <div class=" mt-2 flex flex-col w-max-cbeg_date ">
            <label for="beg_date">Date de début</label>
            <input type="text" class="" name="beg_date" id="beg_date" wire:model="beg_date">          
            @error('beg_date') <span class="text-danger">{{ $message }}</span>@enderror
        </div>
        <div class=" mt-2 flex flex-col w-max-cbeg_date ml-4">
            <label for="end_date">Datend_date</label>
            <input type="text" class="" name="end_date" id="end_date" wire:model="end_date">
            @error('end_date') <span class="text-danger">{{ $message }}</span>@enderror
        </div>
        <div class=" mt-2 flex flex-col w-max-cbeg_date ml-4">
            <label for="close_dclose">Date limite</label>
            <input type="text" class="" name="close_date" id="close_date" wire:model="close_date">
            @error('close_date') <span class="text-danger">{{ $message }}</span>@enderror
        </div> 
        <div class=" mt-2 flex flex-col w-max-content ml-4">
            <label for="receive_registration">Accepte les inscriptions:</label>
            <select class="" name="receive_registration" id="receive_registration" wire:model="receive_registration">
                <option value="no">Non</option>
                <option value="yes">Oui</option>
            </select>
            @error('receive_registration') <span class="text-danger">{{ $message }}</span>@enderror
        </div>
        <div class=" mt-2 flex flex-col flex-auto ml-4">
            <label for="title">Dossier du diaporama</label>
            <input type="text" class="form-control" name="diaporama_dir" id="diaporama_dir" placeholder="ex: admin/1"
                wire:model="diaporama_dir">
            @error('diaporama_dir') <span class="text-danger">{{ $message }}</span>@enderror
        </div>
    </div>
    <div class="mt-2 flex flex-col">
        <label for="abstract">Résumé</label>
        <textarea  class="form-control" name="abstract" id="abstract" wire:model="abstract"
            placeholder="Saisissez votre article"></textarea>
        @error('abstract') <span class="text-danger">{{ $message }}</span>@enderror
    </div>

    <div class="mt-2 flex flex-col">
        <label for="body">Corps de l'article</label>
        <textarea  class="form-control" name="body" id="body" wire:model="body" rows=30
            placeholder="Saisissez votre article"></textarea>
        @error('body') <span class="text-danger">{{ $message }}</span>@enderror
    </div>
    <button wire:click.prevent="store()" class="bg-red-400 px-2 py-1 border rounded-lg mt-2">Enregistrer</button>
    <button wire:click.prevent="resetInputFields()" class="bg-red-400 px-2 py-1 border rounded-lg mt-2">Effacer tout</button>
    <button @click.prevent="mode = 'list'" class="bg-red-400 px-2 py-1 border rounded-lg mt-2 ml-16">Retour à la liste</button>
</form>

update include

The update include is exactly the same as the create include except an additional hidden field for the post id.

What is happening?

At startup, I mean when I visit the localhost:8000/posts page, the page 1 is correctly displayed and the links at the bottom of the page are like localhost:8000/posts?page=3 whichever the number of the page may be.

From this page I can normally go to another page using the bottom links, and this several times.

The troube arises when I click a link to edit a post. The post is correctly sent back by the server but instantly we are switched to page 1 of the paginated posts and the bottom links take a strange form such as localhost:8000/livewire/message/posts.posts?page=3 wichever the page number may be.

The trouble arises also when, after having displayed the create form, I type a first char in the fields. In fact it seems that it arises each time a sync is required.

How can I fix this?

Oct
03
3 weeks ago
Activity icon

Replied to Laravel Livewire How To Use Slot And @yield ?

Thank you. It's good to hear I don't miss it all but, by the way, is there no mean to avoid the creation of an additional template only to render the component's view when it is needed to render it alone on a full page?

Activity icon

Replied to Where Are You All From?

Close to Bayonne, FR

Activity icon

Replied to Laravel Livewire How To Use Slot And @yield ?

Thank you for your answer. It was of great help to me. i now have a better understanding of the mechanism of components and slots as described into the laravel doc and inside this page https://www.larashout.com/using-laravel-blade-components-and-slots. If I understand correctly it is more or less like includes with the additional possibility to populate slots provided into the component when using it in a view template.

Nevertheless, I still have trouble understanding the mechanism that is described in the livewire documentation and make use of it.

Full-Page Components

If the main content of a page is a Livewire component, you can pass the component directly into a Laravel route as if it were a controller.

Route::get('/post', ShowPosts::class);

By default, Livewire will render the ShowPosts component into the {{ $slot }} of a blade layout component located at: resources/views/layouts/app.blade.php

<head>
    @livewireStyles
</head>
<body>
    {{ $slot }}

    @livewireScripts
</body>

I don't understand how it works behind the scene but, provided I accept this, with such a layout I cannot render a normal view. For this I have to provide à @yield('content') directive in the layout, that is not compatible with the rendering of a livewire full page component with the route

Route::get('/register',App\Http\Livewire\Auth\Register::class)->name('register');

If I place both i.e. {{ $slot }} and @yield('content') in the layout, livewire full page components are still rendered but normal views are not. In the last case the server complains that the slot variable is undefined.

Thus my initial question: Should I use a different layout for my normal views (not components)?

But now, after having read all this stuff i am speaking about, I think I could use the @yield('content') directive in the layout, render the livewire components the classic way i.e. livewire:auth.register/ , discard the livewire full page component routing way, recreate a view for the livewire component such as

@section('content')
  <livewire:auth.register>
@endsection

and use the classic routing way

Route::get('/register', function() { return view('auth.register');})->name('register');

Am I right?

Oct
02
3 weeks ago
Activity icon

Started a new Conversation Laravel Livewire How To Use Slot And @yield ?

I am giving a try to laravel8 with livewire. I could manage to achieve registration and login making 2 livewire components register and logger. I use a layout that is very simple at the moment but I am stuck because I don't really understand the use of @yield('content') vs the use of slot. Here is my layout :

<html>
    <head>
        @livewireStyles
        <link rel="stylesheet" href="/css/app.css">  
    </head>
    <body class="  bg-gradient-to-tr from-jbodyleft  via-green-900  to-jbodyleft">
        <div class="bg-blue-300 text-2xl h-10 text-center  my-14">
             @if( auth()->user())
                 {{auth()->user()->firstname}} {{auth()->user()->familyname}} est connecté
            @endif
            </div>
        {{ $slot }}
   
        <div class="bg-blue-300 text-2xl h-10 text-center  my-14">
           This is the footer
       </div>
       @livewireScripts
    </body>
</html>

My routes are :

    Route::get('/', function () {
        return view('home');
    })->name('home');

    Route::get('/register',App\Http\Livewire\Auth\Register::class)->name('register');
    Route::get('/login',App\Http\Livewire\Auth\Logger::class)->name('login');
    Route::get('/logout', function(){ Auth::logout();})->name('logout');

and the home.blade.php is

    @extends('layouts.app')
       @section('content')
           <div class=" flex items-center w-content m-auto p-32 text-4xl">Hello ! I am the home page !</div>
     @endsection

with the layout as it is described before, I correctly display the register and logger pages but not the home page. If I change {{$slot}} with @yield('content') I correctly display the home page but not the register and logger pages. Should I use 2 different layouts ?

Sep
27
3 weeks ago
Activity icon

Started a new Conversation Validation Error Messages Are Not The Ones I Expect

Hi, I use inertia and vue and my error messages on form validation are

"validation.required"

instead of

"The field is required !

Sep
25
4 weeks ago
Activity icon

Replied to Form Data Not Transmitted On Submit

Thank you. I see now. Probably I am a bit tired and confused as I am new to everything . I have another question about passing the existing post to initialize the form. This template is for a single post component I name "details" that is used in a global vue for all posts.I should normally pass it in data() {return form:{ id=null, title=this.details.title ....} but as details (that is a particular post in the list of posts) is lazily loaded, data is not refresh when I need it. In addition using v-model="something" doesn't allow me to initialize an input field. I will post another question.

Activity icon

Started a new Conversation Form Data Not Transmitted On Submit

I use Laravel 8 inertia and vue

I want to update a post and I use this component in a main vue

<template>
<div class="container p-3 bg-green-600 flex flex-col">
    <div class="mb-8 text-2xl">{{ current_post.title }}</div>

    <div v-if="!edit" id="mode-display">
        <div v-html="compiledMarkdown" class="text-gray-700"></div>
    </div>
    <div v-else id="mode-edit">
        <form class="flex flex-col" @submit.prevent="updatePost">
        <input type="hidden" name="id" id="id" v-model="current_post.id">
            <button type="submit">Mettre à jour</button>
            <div class="flex">
                <div class="m-5 flex flex-col">
                    <label for="category">Catégorie du post</label>
                    <select class="px-2" name="category" id="category" v-model="current_post.category">
                        <option value="undefined">Sans</option>
                        <option value="Announcements">Annonce</option>
                        <option value="Narratives">Récit</option>
                        <option value="Pages">Page</option>
                    </select>
                </div>
                <div class="m-5 flex flex-col">
                    <label for="diaporama_dir">Dossier du diaporama</label>
                    <input name="diaporama_dir" id="diaporama_dir" type="text" placeholder="admin|1/Noël2019" v-model="current_post.diaporama_dir">
                </div>

            </div>
            <div class="flex">
                <div class="m-5">
                    <label for="beg_date">Date de début de l'événement</label>

                    <date-picker name="beg_date" format="YYYY-MM-DD" valueType="format" v-model="current_post.beg_date"></date-picker>
                </div>
                <div class="m-5">
                    <label for="end_date">Date de fin de l'événement</label>

                    <date-picker name="end_date" format="YYYY-MM-DD" valueType="format" v-model="current_post.end_date"></date-picker>
                </div>
                <div class="m-5">
                    <label for="close_date">Date de clôture des inscriptions</label>

                    <date-picker name="close_date" format="YYYY-MM-DD" valueType="format" v-model="current_post.close_date"></date-picker>
                </div>
                <div class="m-5 flex flex-col">
                    <label for="receive_registration">Accepte des inscriptions</label>
                    <select class="px-2" name="receive_registration" id="receive_registration" v-model="current_post.receive_registration">
                        <option value="false">Non</option>
                        <option value="true">Oui</option>
                    </select>
                </div>
            </div>

            <input class="p-5 mb-5 text-xl" type="text" v-model="current_post.title" />
            <div class="m-5 flex flex-col">
                <label for="abstract">Résumé</label>
                <textarea class="markdown bg-green-500 text-gray-100" name="abstract" id="abstract" v-model="current_post.abstract" rows="3"></textarea>
            </div>
            <div class="m-5 flex flex-col">
                <label for="body">Résumé</label>
                <textarea class="markdown bg-green-500 text-gray-100" name="body" id="body" v-model="current_post.body" rows="50"></textarea>
            </div>
        </form>
    </div>
</div>
</template>

<script>
import DatePicker from 'vue2-datepicker';
import 'vue2-datepicker/index.css';
import 'vue2-datepicker/locale/fr';

import marked from 'marked';
export default {
    name: "PostDetails",
    props: ["current_post", "edit"],
    components: {
        DatePicker
    },
      data() {
        return {
            
            form:{
                id:null,
                title: null,
                abstract: null,
                body: null,
                category: null,
                beg_date: null,
                end_date: null,
                close_date : null,
                receive_registration : null,
                diaporama_dir: null
            }
        };
    },
    methods:{
      updatePost(){
           this.$inertia.post('/post', this.form);
      }
    },
    computed: {
        compiledMarkdown: function () {
            if (this.current_post) {
                //transform markdown to html
                return marked(this.current_post.body);
            }
        },
        mounted() {},
    }
};
</script>

When displaying this template with the form , I receive a correct post and its values are correctly displayed in the various input fields.

My controller, at the moment is very simple :

public function Update(Request $request)
    {
       dd($request);
    }

On submitting this form the dd outputs this:

Illuminate\Http\Request {#43 ▼
  #json: Symfony\Component\HttpFoundation\ParameterBag {#35 ▶}
  #convertedFiles: null
  #userResolver: Closure($guard = null) {#342 ▶}
  #routeResolver: Closure() {#351 ▶}
  +attributes: Symfony\Component\HttpFoundation\ParameterBag {#45 ▶}
  +request: Symfony\Component\HttpFoundation\ParameterBag {#35 ▼
    #parameters: array:10 [▼
      "id" => null
      "title" => null
      "abstract" => null
      "body" => null
      "category" => null
      "beg_date" => null
      "end_date" => null
      "close_date" => null
      "receive_registration" => null
      "diaporama_dir" => null
    ]
  }
  +query: Symfony\Component\HttpFoundation\InputBag {#51 ▶}
  +server: Symfony\Component\HttpFoundation\ServerBag {#47 ▶}
  +files: Symfony\Component\HttpFoundation\FileBag {#48 ▶}
  +cookies: Symfony\Component\HttpFoundation\InputBag {#46 ▶}
  +headers: Symfony\Component\HttpFoundation\HeaderBag {#49 ▶}
  #content: "{"id":null,"title":null,"abstract":null,"body":null,"category":null,"beg_date":null,"end_date":null,"close_date":null,"receive_registration":null,"diaporama_dir ▶"
  #languages: null
  #charsets: null
  #encodings: null
  #acceptableContentTypes: null
  #pathInfo: "/post"
  #requestUri: "/post"
  #baseUrl: ""
  #basePath: null
  #method: "POST"
  #format: null
  #session: Illuminate\Session\Store {#392 ▶}
  #locale: null
  #defaultLocale: "en"
  -preferredFormat: null
  -isHostValid: true
  -isForwardedValid: true
  -isSafeContentPreferred: null
  basePath: ""
  format: "html"
}

It seems to me I am obeying the guidance given in this page https://inertiajs.com/forms but why on earth the form's value are not uploaded to the server?

Sep
24
1 month ago
Activity icon

Replied to Why My Date Input Doesn't Show The Initial Value Of The Model?

Hi guys! Thank you for your answer. I am absolutely sure the date is good. It is correctly displayed in the text inpu t below the date input. Nevertheless I wrote what usaandi suggests and it was "09/06/2020"

Activity icon

Started a new Conversation Why My Date Input Doesn't Show The Initial Value Of The Model?

I use Laravel 8 inertia vue. I have a model (activerecord) and I would like to update it, particularly a Date column. I use this component's vue

<template>
  <div class="container p-3 bg-gray-100 flex flex-col">
    <div>{{ current_post.title }}</div>
    <div v-if="edit == false" id="mode-diplay">
      <div v-html="current_post.body" class="text-gray-700"></div>
    </div>
    <div v-else id="mode-edit">
      <form class="flex flex-col" action>
        <input type="date" v-model="raw_post.beg_date" >
        <input type="text" v-model="raw_post.beg_date" >
        <input type="text" v-model="raw_post.title" />

        <textarea
          class="markdown"
          name="editor"
          id="editor"
          v-model="raw_post.body"
          rows="50"
        ></textarea>
      </form>
    </div>
  </div>
</template>

<script>
export default {
  name: "PostDetails",
  props: ["current_post", "raw_post", "edit"],

};
</script>

The date input seems to work (though I have not submitted the form yet) but the initial value of raw_post.beg_date is not displayed. Instead I get a placeholder like mm/jj/aaaa which is the French equivalent of mm/dd/yyyy.

Nevertheless the text input below it, works correctly and display the initial value.

How can I have the initial value displayed.

Sep
19
1 month ago
Activity icon

Replied to Don't Understant Ui Scaffolding In Laravel 7

I finally swapped to laravel8 and jetstream. I think the documentation is clearer and I could manage to achieve what I wanted. Thank you for your help.

Activity icon

Started a new Conversation Don't Understant Ui Scaffolding In Laravel 7

I am rather new to laravel. I could manage to create my first site and deploy it, but attempting to create a new one, I stumble over something I probably misunderstand. I am familiar with bootstrap but not at all with vue and react. What I want to do is to setup a new Laravel install with registration verification email nevertheless, reading the installation page on the documentation I bump into this:

Once the laravel/ui package has been installed, you may install the >frontend scaffolding using the ui Artisan command:

// Generate basic scaffolding... 
php artisan ui bootstrap 
php artisan ui vue 
php artisan ui react

// Generate login / registration scaffolding... 
php artisan ui bootstrap --auth
php artisan ui vue --auth 
php artisan ui react --auth

In each of these paragraphs, **shoud I run only one command **or the 3? What troubles me is the fact that after running one command, I am asked to run npm install & npm run dev and each time I am asked if I want to replace numerous templates and controllers.

Sep
15
1 month ago
Activity icon

Replied to My Images Are Visible On Local Server But Not On Hosting's Server

Thank you guys for your answers.

@cwray-tech yes I did. Even several times. But eventually, I removed both storage/app/public and public/storage then recreated storage/app/public, applied php artisan storage:link and put manually my files inside storage/app/public (may be it was public/storage) and it worked.

@SarwarAhmed, your are right assuredly.

Sep
14
1 month ago
Activity icon

Started a new Conversation My Images Are Visible On Local Server But Not On Hosting's Server

I use the laraval filesystem and place images on the public disk. The view in the local laravel built in server are good but after I have pushed my app on remote server. Images are no longer visible.

I must add that, replicating a previous site powered by smfony with several levels of nested directories, I placed the images manually (with a classical file manager) into the storage/app/public/ folder. The links seems to work properly as I can see the folders/files into public/storage.

Can somebody help fixing that.