latz

latz

Member Since 4 Years Ago

Experience Points 10,780
Experience Level 3

4,220 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 93
Lessons
Completed
Best Reply Awards 2
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.

07 Jul
1 week ago

latz left a reply on Birthday List

Thanks for reply. I need raw sql? This is the best way?

latz started a new conversation Birthday List

Hello, I have data with many people. I need a birthday list for the next two month.

Which would be the laravel way to do that? Raw SQL or are there other options?

29 May
1 month ago

latz left a reply on Save Model And Relation

Many thanks!

great support.

27 May
1 month ago

latz started a new conversation Save Model And Relation

i have a model and a many to many relation. My Code to store the request:

  $training = new Training([
              'training' => $request->get('training'),
              'art' => $request->get('art'),
            ]);
            $training->save();
       
        foreach ($request->get('id') as $player) {
            $training->players()->attach($player['id'], ['status' => $player['status']]);
        }

First i save the model and then the data for the relation.

My problem: If an error occurs while saving the relationship data, the model has already been saved. How can I prevent this?

21 Apr
2 months ago

latz left a reply on Array Of Radio Buttons

Thanks. I searched with the wrong term.

latz started a new conversation Array Of Radio Buttons

Hello,

i have an table with persons. Now i need to assign characteristics (with radio buttons)

Example: ..... male female Peter () () Elisabeth () () Johny () ()

How can I tackle this problem?

19 Apr
3 months ago

latz left a reply on Problem With German Date Format

After i remove the part of the validation: unique:trainings it works.

With the unique settings i've got the error;

Perhaps you need a different "datestyle" setting. (SQL: select count(*) as aggregate from "trainings" where "trainingsdate" = 30.12.2019

Lumen takes the date in the request array. this is the "wrong" german date. Do I understand this wrong?

Two sql querys:


select count(*) as aggregate from "trainings" where "trainingsdate" = '2019-12-30'

select count(*) as aggregate from "trainings" where "trainingsdate" = '30.12.2019'

The first works. The second not.

18 Apr
3 months ago

latz left a reply on Problem With German Date Format

Thanks. I tried to convert the timestamp

$trainingsdate = Carbon::createFromFormat('d.m.Y', $request->get('trainingsdate'))->toDateTimeString();
print_r($trainingsdate);

I've got an error, too. The error is probably due to the validation.

'trainingsdate' => 'required|unique:trainings|date|date_format:d.m.Y'

The unique field is the problem?

latz started a new conversation Problem With German Date Format

Hello,

i have problems with german date format and postgresql.

this is part of json request to the API: trainingsdate: "21.02.2019"

Validation in the controller:


        $this->validate($request, [
            'art' => 'required|max:1|min:1',
            'trainingsdate' => 'required|unique:trainings|date|date_format:d.m.Y'
        ]);

and save the data to the database:

$training = new Training([
            'trainingsdate' => $request->get('trainingsdate'),
            'art' => $request->get('art'),
          ]);
        $training->save();

I've got an error:

SQLSTATE[22008]: Datetime field overflow: 7 ERROR: date/time field value out of range: "21.02.2019"

My timezone is set it to Europe/Zurich How can i use the german date format (dd.mm.yyyy) in lumen?

13 Apr
3 months ago

latz left a reply on Problems With Many To Many Relation

@bobbybouwmann Yes, it works for me.

Thanks!

latz started a new conversation Problems With Many To Many Relation

Hello, i need help. My Problem: My API receives a http post within json. Looks like:

{ "trainingday": "02.02.2019", "art": "T", "player": [ { "id": 2, "firstname": "Peter", "lastname": "Mayer", "choose": true }, { "id": 3, "firstname": "Martin", "lastname": "Fox", "choose": true }, { "id": 4, "firstname": "Andreas", "lastname": "Lion", "choose": true } ] }

I want to save the first part to the training model:

$training = Training::create($request->all());

This works fine.

In the next step, i want to save the player array to a many to many relationship table.

$training->players()->attach($request->id, ['art' => "t", 'choose' => false]);

*(art and choose) static data for testing

That doesn't work. Error Message: SQLSTATE[42703]: Undefined column: 7 ERROR: column "lastname". It looks like there is more info in the array than necessary. Laravel wants to save everything. How can i save the player data in the database? I can't change the json.

26 Feb
4 months ago

latz left a reply on Ping To Homestead Is Fine But Connection Refused

Login to homestead with ssh. Is nginx running?

latz left a reply on Create New Row And Sync Many To Many Relationship

Many thanks for your solution. It works.

latz left a reply on Incorrect Disk Space?

take a look:

cd /
ls -la

Now you see the folders. Get the size:

du -hs /bin
du -hs /boot
du -hs /dev
du -hs /home
du -hs /lib
...
25 Feb
4 months ago

latz started a new conversation Create New Row And Sync Many To Many Relationship

I would like to schedule appointments with my application. I want to capture the participants. There are three tables: student, event and student_event.

My wish: I create an event and assign the participating students in one step.

If i know the id from the event table, this code works:

$id = 3;
$event =  Event::findOrFail($id);
$event->students()->sync($request->id);

How can I create a new event record and then assign the participants?

My form looks like (filled):

Event: "2019-02-01" Student A: x Student B: - Student C: - Student D:x Student E: x Submit

21 Dec
6 months ago

latz left a reply on Vuejs - Local Dev With Different Url

Sorry, I forgot to say: i have different URLs for backend and frontend. e.g. api.xyz.com and app.xyz.com

latz started a new conversation Vuejs - Local Dev With Different Url

Hi,

I have a local environment with lumen and a vue spa. So I am not sure how to handle different URLS: Local and Live. e.g.: local: localhost:1234 live: www.xyz.com

What do you think is the best way to solve this problem?

best regards markus

08 Dec
7 months ago

latz left a reply on Date And Time Format With Api And Vue

Yeah, you made my day. It works. Yesterday I tried a similar solution. But unfortunately with the wrong variables.

Great support @realrandyallen !

Thanks markus

07 Dec
7 months ago

latz left a reply on Date And Time Format With Api And Vue

I've got an error, too.

:value="formatDate(newItem.tsmp)" conflicts with v-model on the same element because the latter already expands to a value binding internally

latz left a reply on Date And Time Format With Api And Vue

Many thanks for your reply.

I have problems in vue.

the form code has this row

<input type="text" class="form-control" v-model="newItem.tsmp" />

lumen delivers a timestamp. I have problems to convert the timestamp into german date.

This is not working:

<input type="text" class="form-control" v-model="newItem.tsmp | formatDate" />

Error: Property or method "formatDate" is not defined on the instance but referenced during render.

How can I solve this problem?

latz started a new conversation Date And Time Format With Api And Vue

Hi, i have trouble with the beginning with vue. I need a simple form with title, date and time. Only these three details are needed. But i need german date format (dd.mm.YYYY).

A possibility is working with unix timestamp. I save this in the database und transform it in the lumen backend and vue frontend. This looks very difficult. Specially with vue. Or is it better to use the date string in all areas?

28 Sep
9 months ago

latz started a new conversation Big Problems Mit Adldap And Windows Directory

Hello, I have trouble with adldap. I try to connect to a windows active directory.

The loginscreen from Laravel works with eloquent. If i switch to adldap, the login mask doesn't work. After submitting the mask remains without error. I found no hint in the logfiles.

This Code works in a "normal" Controller: ```$user = Adldap:auth()->attempt("joe","foo");```` I get a "true" and a "false" with wrong password.

In the Config-File "adldap_auth.php" I use the NoDatabaseUserProvider::class.

The array "username" uses at "ldap" the value 'samaccountname'.

Something is still wrong. I hope someone can help me.

Best regards

17 Sep
10 months ago

latz started a new conversation Laravel Passport With LDAP

Hello,

is it possible to use Laravel Passport with LDAP? (Authentication against Active Directory) How can I get that?

11 Aug
11 months ago

latz left a reply on Vue Post To Api And Catch Request With Controller

@tykus Many thanks. You made my day.

Great support and and patience. I don't know how I solved it by myself.

Best regards

latz left a reply on Vue Post To Api And Catch Request With Controller

dd($players);

Collection {#189
  #items: array:4 [
    0 => array:1 [
      1 => array:1 [
        "visit" => "X"
      ]
    ]
    1 => array:1 [
      2 => array:1 [
        "visit" => "X"
      ]
    ]
   ...
}

latz left a reply on Vue Post To Api And Catch Request With Controller

I've got an error:

"Array to string conversion (SQL: insert into "player_training" ("player_id", "training_id", "0") values (0, 1, X))

I think the player_id is wrong. It's really difficult.

latz left a reply on Vue Post To Api And Catch Request With Controller

@tykus Yeah, you are great.

Is it possible to use the sync option? The alternative is to delete everything before the update.

latz left a reply on Vue Post To Api And Catch Request With Controller

The pivot table has four fields: id player_id (Relation to player table) training_id (Relation to training table visit (Field for status)

The Vue form provides more data "id":1,"firstname":"Emma","lastname":"Gomez","tdate":"2018-03-03","visit":"X"

Thank you for your patience.

latz left a reply on Vue Post To Api And Catch Request With Controller

I have a many to many pivot table. The Fields: id player_id training_id visit

Currently, Laravel says I have more data in my post than fields (Undefined column).

This works only with Laravel. (But I changed the database). Controller:

....
$training = Training::find($id);
$training->players()->sync($spieler); 
...

If I did that ...

latz left a reply on Vue Post To Api And Catch Request With Controller

@tykus @Abi

Great! The first Problem is solved :) Many thanks.

Next problem is the database. I will try it.

latz started a new conversation Vue Post To Api And Catch Request With Controller

Laravel and Vue make fun. But at the beginning it's very difficult.

I want to post a form with axios to the api. This is the submitted payload:

[{"id":1,"firstname":"Emma","lastname":"Gomez","tdate":"2018-03-03","visit":"X"},{"id":2,"firstname":"Jacob","lastname":"Miller","tdate":"2018-03-03","visit":"D"}...

Vue:

saveForm() {
                axios.post('/api/training/'+this.$route.params.id+'', this.players)
                .then(response => { ...

Laravel Controller:

public function update(Request $request, $id)
    {
        $players = $request->players;

This ist my first problem. $request->players is empty.

How do I get access to the request?

The next problem we will be the database. But one after the other.

Best regards

10 Aug
11 months ago

latz left a reply on Form With Array - Problem With Select Options

Thanks for your reply.

This is new territory for me. How should I proceed?

latz started a new conversation Form With Array - Problem With Select Options

Hello, i need a form to edit some data. From the Api I receive the following data

[{"id":1,"firstname":"Emma","lastname":"Gomez","tdate":"2018-03-03","visit":"X"},{"id":2,"firstname":"Jacob","lastname":"Miller","tdate":"2018-03-03","visit":"D"}...

I would like to list the data and change the visit-state.

 <ul v-if="players">
            <li v-for="{ id, firstname, lastname } in players">
            {{ firstname }} {{ lastname }} 
                <select>
                <option value="X">Present</option>
                <option value="E">Excuse</option>
                <option value="D">Diseased</option>
                </select>
          </li>
        </ul>

```
My first problem: How can i list the received data?
The players are displayed. But the old Value is not selected and in the second step i want to save the changes to the api. 
Thanks for help.

07 Aug
11 months ago

latz started a new conversation Problems With Many To Many Relationship

Hi, i have a many to many relationship. This raw sql show the desired result:

FROM player_training
INNER JOIN players
ON players.id = player_training.player_id
WHERE training_id = 2```

How can i get the same result with eloquent?

I have three tables:
- players
- trainings
- player_training

I need the data from a trainingday.


20 Jul
11 months ago

latz started a new conversation Mixing Vue SPA With Laravel Routes

Hello everybody,

i want to start with vue. Is it possible to use Vue as a SPA and laravel for some routes?

Example: Vue catch the url: /player /player/id /player/scores

Laravel provides /news /photos /teams

Maybe someone knows a page that uses this?

13 May
1 year ago

latz left a reply on Laravel Passport - Only For Js?

Thanks for the reply.

Is it possible to use laravel as a client? I have a running passport server and the laravel application should use this for authentication. Is this possible?

latz started a new conversation Laravel Passport - Only For Js?

Hi, is it possible to use passport with laravel? Or is it restricted to javascript?

Probably is it not possible to mix passport with the default (session based) authentication?

24 Mar
1 year ago

latz left a reply on SPA With Laravel - Domain API

ok. Many thanks.

latz left a reply on SPA With Laravel - Domain API

I'm sorry. I want divide the frontend with the backend.

latz left a reply on SPA With Laravel - Domain API

Thanks for the reply.

I don't like to mix laravel or lumen with the spa. That's the reason why i don't divide laravel and angular or vuejs. Maybe there are other solutions? Is it possible to use to different folders? I have no opportunity to configure the webserver.

latz started a new conversation SPA With Laravel - Domain API

Hi, i would like to built a SPA. I use laravel or lumen for the backend. Perhaps Angular 5 or vuejs for the frontend. Is it better to use a subdomain for the api (api.xyx.com) or is it possible to use one domain for the complete webapplication? I want two separate applications. Which solution is suitable? Any hints?

best regards markus

15 Feb
1 year ago

latz left a reply on Raw Sql-select

It's allright. @Snapey answer the question about the eloquent model.

I use Carbon for the date format and now i'm happy.

Thank you for your help

best regards markus

latz left a reply on Raw Sql-select

@bobbybouwmann

Here is the working select:

 $massage = DB::table('courses')
        ->selectRaw("*,
                    (SELECT COUNT(*)
                    FROM appointments
                    WHERE p ='x'
                    AND appointments.id = course.id
                    GROUP BY course_id
                    ) as fp")->get();

latz left a reply on Raw Sql-select

Thanks for your reply. I tested the "selectRaw". The query received a value. So the first step works. :)

But the next problem is the date format. The get attribute in the model seems to be ignored. The date format is wrong. Am i right, the the attribute works only with eloquent?

14 Feb
1 year ago

latz started a new conversation Raw Sql-select

Hello,

i have a problem with a raw SQL-select. This Code works in Laravel 5.2:

$massage = DB::table('course')
                     ->select(DB::raw("*,
                            (SELECT COUNT(*)
                             FROM appointments
                             WHERE p ='x'
                             AND appointments.id = course.id
                             GROUP BY A_id
                             ) as fp,
                    ...
            ...
                            "))->get();

I've got a value for the the variable "fp".

With Laravel 5.5 the value "fp" is empty.

With the raw-select the get and set attributes in the model doesn't work, too.

For a better understanding: I have a table with sport courses. The table course has a many relation to the table appointments. I need the count of the booked appointments.

How can i solve my problem?

Best regards Markus

10 Jan
1 year ago

latz left a reply on Json Output - Wrong Order - Eloquent

this works for me: $roles = Role::orderBy('id')->get();

many thanks tykus.

latz started a new conversation Json Output - Wrong Order - Eloquent

Hello,

i have a problem and i don't know where it is.

My Controller has a function to get all roles.

$roles = Role::all()->sortBy("id");
dd($roles)

Output:
 #items: array:6 [▼
    0 => Role {#293 ▶}
    1 => Role {#294 ▶}
    4 => Role {#297 ▶}
    5 => Role {#298 ▶}
    2 => Role {#295 ▶}
    3 => Role {#296 ▶}
  ]

The json-output has the wrong sorting. I need this sequence: 0 =>... 1 => ... 2 => ... 3 => ... 4=> ... Changing the the sortby option does not help. The Keys are always the same. Why?

How can i solve this problem?

best regards. markus

20 Aug
1 year ago

latz started a new conversation Which Relationships Is The Right One For Me?

I have the following plan: There is a team in the tennis club. I would like to record the training visits. I have a table player. Finally, I would like to evaluate the visits from every player. Or the trainingday with the most players.

Which is the correct Relationship for my purpose? Is it one to many or many to many?

03 Aug
1 year ago

latz left a reply on Format Date - Json Output

thanks for the reply.

I need the query bilder for a complex select.

Is it possible to format the date in the sql select? I use postgresql. Any Ideas?

latz started a new conversation Format Date - Json Output

I have problems with date-format in json-output.

In the model i use an accessor '''' public function getdatumAttribute($value) { return Carbon::parse($value)->format('d.m.Y'); } ''' With eloquent this works fine. I've got the correct format of the datefield.

If i use the select: '''' $player = DB::table('players')->select(DB::raw("*, .... .... return $player; '''' the accessor doesn't work und the output of any date is wrong (for me). Why does the accessor not work with the db-select and how can i format the date in json output?

best regards