mlutz

Experience

9,900

2 Best Reply Awards

  • Member Since 3 Years Ago
  • 91 Lessons Completed
  • 1 Favorite

11th August, 2018

mlutz left a reply on Vue Post To Api And Catch Request With Controller • 1 week ago

@tykus Many thanks. You made my day.

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

Best regards

mlutz left a reply on Vue Post To Api And Catch Request With Controller • 1 week ago

dd($players);

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

mlutz left a reply on Vue Post To Api And Catch Request With Controller • 1 week ago

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.

mlutz left a reply on Vue Post To Api And Catch Request With Controller • 1 week ago

@tykus Yeah, you are great.

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

mlutz left a reply on Vue Post To Api And Catch Request With Controller • 1 week ago

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.

mlutz left a reply on Vue Post To Api And Catch Request With Controller • 1 week ago

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 ...

mlutz left a reply on Vue Post To Api And Catch Request With Controller • 1 week ago

@tykus @Abi

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

Next problem is the database. I will try it.

mlutz started a new conversation Vue Post To Api And Catch Request With Controller • 1 week ago

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

10th August, 2018

mlutz left a reply on Form With Array - Problem With Select Options • 1 week ago

Thanks for your reply.

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

mlutz started a new conversation Form With Array - Problem With Select Options • 1 week ago

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.

7th August, 2018

mlutz started a new conversation Problems With Many To Many Relationship • 1 week ago

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.


20th July, 2018

mlutz started a new conversation Mixing Vue SPA With Laravel Routes • 1 month ago

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?

13th May, 2018

mlutz left a reply on Laravel Passport - Only For Js? • 3 months ago

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?

mlutz started a new conversation Laravel Passport - Only For Js? • 3 months ago

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?

24th March, 2018

mlutz left a reply on SPA With Laravel - Domain API • 4 months ago

ok. Many thanks.

mlutz left a reply on SPA With Laravel - Domain API • 4 months ago

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

mlutz left a reply on SPA With Laravel - Domain API • 4 months ago

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.

mlutz started a new conversation SPA With Laravel - Domain API • 4 months ago

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

15th February, 2018

mlutz left a reply on Raw Sql-select • 6 months ago

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

mlutz left a reply on Raw Sql-select • 6 months ago

@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();

mlutz left a reply on Raw Sql-select • 6 months ago

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?

14th February, 2018

mlutz started a new conversation Raw Sql-select • 6 months ago

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

10th January, 2018

mlutz left a reply on Json Output - Wrong Order - Eloquent • 7 months ago

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

many thanks tykus.

mlutz started a new conversation Json Output - Wrong Order - Eloquent • 7 months ago

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

20th August, 2017

mlutz started a new conversation Which Relationships Is The Right One For Me? • 1 year ago

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?

3rd August, 2017

mlutz left a reply on Format Date - Json Output • 1 year ago

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?

mlutz started a new conversation Format Date - Json Output • 1 year ago

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

27th June, 2017

mlutz started a new conversation Authentication Class For Passport • 1 year ago

How can i check if the user is authenticated? With the right user and password the user gets a token. I save with

 localStorage.setItem('currentUser', JSON.stringify(responseData));

Now i need a class to check if the user is authenticated. Has someone an example?

mlutz left a reply on Laravel Boilerplate On Hosting Server: Error -> Public/login Was Not Found On This Server. • 1 year ago

Perhaps the RewriteBase is not correct. Try a comment out.

9th June, 2017

mlutz left a reply on Architecture With Laravel And Vue • 1 year ago

thanks for your reply.

but are both ways practicable?

Is it better to use laravel with a single vue component or a complete single page app? What disadvantages result from the two options?

8th June, 2017

mlutz started a new conversation Architecture With Laravel And Vue • 1 year ago

Hello, i'm interested in learning vue. I need a hint to use vue with laravel.

Normally there is a api. eg: /api/player /api/club

In the front end I want to use vue to show the data. e.g. /player and /club and more...

How will it work in practice? Is there one single page with vue (one script with routing)? Or is it possible to use a separate vue script for every page?

regards markus

7th June, 2017

mlutz left a reply on Laravel Passport Api With Laravel • 1 year ago

Thanks. I'm searching for a tutorial with example code. Passport is running fine und i can use it with postman. But how can i use passport with laravel. Is it possible? Or is the better to use passport (authentication) with a js framework?

mlutz started a new conversation Laravel Passport Api With Laravel • 1 year ago

I am searching for a tutorial to use laravel with passport. Is it possible to use passport with laravel or is it better to use javascript (angular, vue ...).

8th February, 2017

mlutz left a reply on Just Combine Js-files • 1 year ago

Yeah, this works. npm runs without an error.

But without the npm-manager there is no chance to combine the files? In the best case i manage the files by myself.

Other Tools like Bower are out of the box in 5.4?

mlutz left a reply on Just Combine Js-files • 1 year ago

Hi Jeffrey,

i tried it with ''' const { mix } = require('laravel-mix'); mix.js([ 'resources/assets/vendor/jquery-2.2.4.js', 'resources/assets/vendor/materialize-src/js/bin/materialize.js' ], 'dist/app.js'); ''' too but the same error: ''' ERROR Failed to compile with 1 errors

This dependency was not found in node_modules:

  • hammerjs '''

hammerjs is required by materialize.js, but it's included in the complete file of materialize. Perhaps it's better to use a task manager like gulp?

best regards markus

mlutz started a new conversation Just Combine Js-files • 1 year ago

Hi, i just want to combine two js files.

My webpack.mix.js file: ''' mix.combine([ 'resources/assets/vendor/jquery-2.2.4.js', 'resources/assets/vendor/materialize-src/js/bin/materialize.js' ], 'dist/app.js'); '''

I've got an error: This dependency was not found in node_modules:

  • hammerjs

Is it possible to combine this two files without a check from webpack?

7th February, 2017

6th February, 2017

mlutz left a reply on 5.4 - Mix - Javascript • 1 year ago

Thanks. I've got it.

mlutz started a new conversation 5.4 - Mix - Javascript • 1 year ago

Hello, i have problems to understand the new laravel mix. I want to put some Librarys (jquery, jquery-plugins) in one file. In another file the satisfy code. With gulp it was easy with "mix.scripts". I have a bower directory with some plugins. And now?

30th January, 2017

mlutz left a reply on Validation UserRequest - Unique E-Mail • 1 year ago

yeah. $this->route('users'),

I don't know why, but it works.

many thanks.

mlutz left a reply on SQLSTATE[HY000] [1045] Access Denied For User 'homestead'@'localhost' (using Password: YES) (SQL: Select * From `products`) • 1 year ago

Ok. This is another Error Massage? Did you change the mysql port back in the .env file?

mlutz left a reply on SQLSTATE[HY000] [1045] Access Denied For User 'homestead'@'localhost' (using Password: YES) (SQL: Select * From `products`) • 1 year ago

try: php artisan config:cache and php artisan config:clear

mlutz left a reply on Validation UserRequest - Unique E-Mail • 1 year ago

I'm sorry. It doesn't work, too.

mlutz left a reply on SQLSTATE[HY000] [1045] Access Denied For User 'homestead'@'localhost' (using Password: YES) (SQL: Select * From `products`) • 1 year ago

change the mysql port in the .env file. You probably see an error like "could not connect to server: Connection refused" and "running...port..."

mlutz left a reply on SQLSTATE[HY000] [1045] Access Denied For User 'homestead'@'localhost' (using Password: YES) (SQL: Select * From `products`) • 1 year ago

The error says: Access denied for "homestead". .env has an another entry.

Windows system?

mlutz started a new conversation Validation UserRequest - Unique E-Mail • 1 year ago

I have trouble with a crud-resource for users.

I use for validation an own UserRequest UserController:

public function update(UserRequest $request, $id) {..}

UserRequest:

'email' => 'unique:users,email'.$id,

My Form:

{{ Form::model($user, array('method' => 'PATCH', 'route' => ['admin.users.update', $user->id], 'class' => 'form-horizontal')) }}

When i edit an user, I've got an error (Undefined variable: id). How can i catch the User->id in the Request-Class? Is it necessary to use a hidden field with the user-id?

22nd January, 2017

mlutz started a new conversation SQL Select With Subselect • 1 year ago

Hi,

i have this select:

select *, 
(
SELECT COUNT(*)
FROM docappointments
WHERE pn ='1'
AND doc_id = r.id
GROUP BY doc_id
)

FROM docs as r

How can i use this select in laravel? Is it possible to use this select in eloquent?

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.