Tomi

Tomi

Member Since 1 Year Ago

Full Stack Developer at Connex Marketing GmbH

Experience Points 35,020
Experience Level 8

4,980 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 271
Lessons
Completed
Best Reply Awards 10
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 May
1 month ago

Tomi started a new conversation Laravel Passport Scopes For 3rd Party Client App

Hallo,

If i understand this correctly i can only use scopes if the Passport package is installed in my client application, and not if the Passport lives in a separate Laravel application (Auth Server)

Route::get('/orders', function () {
    // Access token has both "check-status" and "place-orders" scopes...
})->middleware('scopes:check-status,place-orders');

I googled quit a bit about this "problem" but no real suggestions or "correct" ways to follow.

Right now i have my Clinet App where i have API Routes like:

post: /vouchers get: /vouchers/ABC12345

and so on this are all protected by my custome middleware (voucher-auth).

The Middleware checks if there is a User in my redis with an access_token that is given to the server by a Cookie. If there is no User in the redis cached, then it makes a HTTP Request to auth.mydomain.com/me This is my Auth Server. The /me Route is protected by passports auth:api middleware so from there Larave Passport checks if the Bearer token is correct and if he finds a User it will be returned and Cached in my Client App.

Im not even quit sure how good this solution but this is the best i could come up with.

The problem is i dont know how to go with the Permissions. Cause is i said the Routes Live in the Clinet App.

12 May
1 month ago

Tomi left a reply on Laravel Personal Access Client

Yeah i understand the purpose of the access token, just want quit sure why i need a personal access client. And if i need to make a personal access client for every one of my services.

10 May
1 month ago

Tomi started a new conversation Laravel Personal Access Client

Hello,

so at my Company we are implementing Laravel Passport as an OAuth solution for our Service Architecture.

Lets say there is a Job running in one Service , call it Order Service, thats wants information about the Products so makes an https request to the Order Service : (https://order-service.myhost.com/api/v1/products/123 ).

This route is guarded with a middleware that goes to my Passport auth Server with a bearer token to see if the request is authorized.

Whats the correct solution for this? I thought i am using Personal Access Tokens (PAT), but as i understood it, for this i have to create User thats corresponding to me Product Service something like Product User, and for this user ill have to create a PAT.

But with this token i can also go to every other service that is using the middleware.

Also whats the point of the Personal Access Client?

06 May
1 month ago

Tomi left a reply on How Copy Url Laravel Route In Model Vue Js

try: console.log(window.location.href );

03 May
1 month ago

Tomi left a reply on Dynamic Var Name By Store Method

${'a' . 'b'} = 'hello there';
echo $ab; // hello there

Tomi left a reply on Array Issue

        $newArray = [];
        foreach($array1 as $key1=>$value1) {
            $newArray[$value1] =$array1[$value2];
        }

im sure you can also do it with some kinde of array helper functions as well, ley array_keys array_values and megre.

Tomi left a reply on Frontend 'module' Enable/disable From Backend

If its a normal Laravel application using blade and not an SPA. I would just straight go with Policy.

https://laravel.com/docs/5.8/authorization#via-blade-templates

@can('update', $post)
    <!-- The Current User Can Update The Post -->
@elsecan('create', App\Post::class)
    <!-- The Current User Can Create New Post -->
@endcan
29 Apr
1 month ago

Tomi left a reply on To Display Only Once

well $suggestions is a collection of 4 items. You could try first.

like $suggestions->first()->category or something like that. Or you could just figure out in your backend why you have the same category 4 times.

Or super ugly: <?php return ''; ?> after the first br.

Tomi left a reply on Getting Data Using With() Relation In Controller To Js

have you tryd to console.log(campusObj) and see whats your result?

Tomi left a reply on Calculate Difference (carbon), To Save Extra Database Field

for mysql there is the function TIMEDIF

SELECT TIMESTAMPDIFF(SECOND, '2012-06-06 13:13:55', '2012-06-06 15:20:18') you can create a DB::raw() query and select the rows like that.

Tomi left a reply on Check If Laravel Works With Redis After Module Installation

well you can install https://github.com/barryvdh/laravel-debugbar and see if there is any db query or the querys for the models you cached. If no querys are fired then its cached.

Tomi left a reply on Need Help In Laravel Spatie Google Calendar Package

https://imgur.com/a/0JO0eOW

you go into google calender, then the settings wheel on the top right. Then on the left you pick the calender you want and then go to specific people settings, there you can add the ID you created.

26 Apr
1 month ago

Tomi left a reply on Trouble Understanding How A Vue Plugin Is Working

@dunsti yea basicly just two different random IDs. Also i would just try to include datepicker without a commponend wrapped around it and see if it works.

25 Apr
1 month ago

Tomi left a reply on How To Handle/follow Guzzle Redirects Within Laravel

you can use laravels redirect() function to redirect to the page you want.

https://laravel.com/docs/5.8/redirects

Tomi left a reply on Laravel 5.8 - Cutom Rule Validation With Array With Values As Paramter And Query Database

Your approach is okay. But you should not do this: car = '$value['car']'. You are passing the data from the input directly to the database and allow for sql injections. Try to use databinding or the Query Builder.

Tomi left a reply on Laravel Error "array_map(): Argument #2 Should Be An Array"

In your Validator as second parameter you suposed to pass the rules for the validation. For example.

     $validator = Validator::make($request->all(), [
            'title' => 'required|unique:posts|max:255',
            'body' => 'required',
        ]);

in your example you are adding the values from your request.

Tomi left a reply on Trouble Understanding How A Vue Plugin Is Working

Hi,

not sure if this is a vue specific problem or the airbnb plugin got an internal bug. Try adding the :key prop with different values to both of your airbnb components.

Key is usually added for list rendering but might help.

https://vuejs.org/v2/guide/list.html#key

Tomi left a reply on Write A Command Line Script In Laravel To Check Courses?

Hello,

not sure if i understand correctly but do you need a Scheduler?

https://laravel.com/docs/5.8/scheduling

You can use this to schedule functions or tasks.

    protected function schedule(Schedule $schedule)
    {
        $schedule->call(function () {
            DB::table('recent_users')->delete();
        })->daily();
    }

If you need a command line tool that you can run by yourself, you can just simple make your own artisan command:

https://laravel.com/docs/5.8/artisan

29 Nov
6 months ago

Tomi left a reply on Laravel Passport Oracle DB Error

Just an update for anyone getting this problem:

https://github.com/laravel/passport/issues/895

It also helps if you Override the model:

in you auth Service Provider:

Passport::useAuthCodeModel(AuthCode::class);

Then you create your own AuthCode::class and extend it from the passport AuthCode model, then set incrementing to false.

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class AuthCode extends \Laravel\Passport\AuthCode
{
    public $incrementing = false;
}

27 Nov
6 months ago

Tomi started a new conversation Laravel Passport: Authorization_code

Hello,

I implemented Laravel Passport as a standalone OAuth2 server, and im consuming the API with a Single Page App also created in Laravel.

My question is more about the Authentification. I got this code from the Laravel Passport Docs:

Route::get('/redirect', function () {
    $query = http_build_query([
        'client_id' => 'client-id',
        'redirect_uri' => 'http://example.com/callback',
        'response_type' => 'code',
        'scope' => '',
    ]);

    return redirect('http://your-app.com/oauth/authorize?'.$query);
});

Route::get('/callback', function (Request $request) {
    $http = new GuzzleHttp\Client;

    $response = $http->post('http://your-app.com/oauth/token', [
        'form_params' => [
            'grant_type' => 'authorization_code',
            'client_id' => 'client-id',
            'client_secret' => 'client-secret',
            'redirect_uri' => 'http://example.com/callback',
            'code' => $request->code,
        ],
    ]);

    return json_decode((string) $response->getBody(), true);
});

I got this code inside my client app. In the callback route i get a Token back wich i store in a Cookie and use it each time i want something from the server, lets say i need user information.

It works all fine as expected, but one thing i noticed. The user can call the /redirect route as much as he wants and this will always generate new access tokens even if the user already got one.

Do i have to prevent the user from doing this? Or is this a job from Passport and i just did configure it wrong?

22 Nov
6 months ago

Tomi left a reply on SSO With Socialite And Passport

@JoeDawson hello, sorry for bothering you. I am having a similar issue to yours. You mind if i ask if you still remember your solution for the SSO?

I would be interested in your SSO Socialite provider.

Tomi started a new conversation SSO With Socialite And Passport

Hi every one,

So im working on a new project where we have to implement an Authentication Server, where the clients can login and then they get redirected to the original consumer Page.

I use Laravel Passport as an OAuth2 solution. I sett up a code grant Auth. Something like this:

Client web.php:

`Route::get('/redirect', function () {

$query = http_build_query([
    'client_id' => '1',
    'redirect_uri' => 'https://client-website.com/callback',
    'response_type' => 'code',
    'scope' => ''
]);

return redirect('https://server-website.com/oauth/authorize?'.$query);

});

Route::get('/callback', function (Request $request) { $http = new GuzzleHttp\Client;

$response = $http->post('https://server-website.com/oauth/token', [
    'form_params' => [
        'grant_type' => 'authorization_code',
        'client_id' => '1',
        'client_secret' => 'tqkh59V6y2Tr2AxGn1IcCLV4awUt5reU7qop4rH0',
        'redirect_uri' => 'https://client-website..com/callback',
        'code' => request()->code,
    ],
]);


return json_decode((string) $response->getBody(), true);

});`

After this i get an access_token back. The tricky part is we also need an SSO implementation, and this is where it gets quit confusing for me. I recently read a different topic where it was brought up that Socialite could be used as an SSO.

If not did anyone else had a similar issue ? I got my token so how could i share it across all of my sites?

Tomi left a reply on Laravel Passport Oracle DB Error

yap it its oracle, it works perfectly with sqlite.

Tomi left a reply on Laravel Passport Oracle DB Error

My bigger problem is that last binding, the 0 one. And i think thats the problem why it says: returning "ID" into :p6 Bindings

Tomi started a new conversation Laravel Passport Oracle DB Error

down vote favorite DB: Oracle Laravel: 5.7

While i Passport is trying to persist the new Token for the User it gives following error and not creating any toke.

Error Code : 1722 Error Message : ORA-01722: Invalid Number : 145 Statement : insert into "OAUTH_AUTH_CODES" ("ID", "USER_ID", "CLIENT_ID", "SCOPES", "REVOKED", "EXPIRES_AT") values (:p0, :p1, :p2, :p3, :p4, :p5) returning "ID" into :p6 Bindings : [da3315abd6a4fe597465898a76feb95fdf8e8116ee64c3889516842a6fa7418e4cf3e030fb8f3445,434,1,[],0,2018-11-22 13:00:44,0]

Not sure if its an oracle issue, or if i am doing something wrong with the Passport setup, but don't think there are lot of things where it could go wrong while setup.

For me it seems there is an additional 0 at the end, not sure why this happen. Anyone had a similar issue so pl help?

13 Nov
7 months ago

Tomi left a reply on File Uplaod Error (Call To A Member Function Store() On Null)

Is the data (file) in your request?

25 Oct
7 months ago

Tomi left a reply on Vue: Property Or Method "APP" Is Not Defined On The Instance But Referenced During Render.

you should try to pass the APP to a Data prop in you Vue app.


data() {
    return {
        app: APP
    }
}

22 Oct
7 months ago

Tomi left a reply on How To Add Vuex To Laravel Nova?

found the solution , i leave it here might some one gets the same problem:

https://vuejs.org/v2/guide/mixins.html#Global-Mixin

Tomi started a new conversation How To Add Vuex To Laravel Nova?

So i am working on a new Tool for Nova, and i need Vuex to make it work. Is there a way to add Vuex to laravel Nova?

I would usually just add it in the Vue instance:

store js:

import Vuex from 'vuex';


Vue.use(Vuex);

app.js:

import {store} from './store/store';


new Vue({

    el: '#prm',

    i18n,

    store,

but in the tools.js component the Vue instance is already defined and this sadly doesnt work:

Nova.booting((Vue, router) => {
    router.addRoutes([
        {
            name: 'voucher-editor',
            path: '/voucher-editor',
            component: require('./components/Tool'),
        },
    ])
})

Vue.store = store;

Any one had a problem like this? How do you add in general new plugins to an existing Vue instance?

17 Oct
8 months ago

Tomi started a new conversation Laravel Nova Action Fields

Hello,

so i just installed Nova set up some Resources, it shows everything fine, but when i try to update any of them, i get a Database error that i cant insert NULL into ACTION_EVENT.FIELDS.

https://nova.laravel.com/docs/1.0/actions/defining-actions.html#action-fields

The Doc says i can define some fields in the Actions fields function , but i didnt generate any Action class not i want to. I think its some sort of default action logging?

Can i turn it off, or do i have to add some Fields somewhere?

08 Oct
8 months ago

Tomi left a reply on Vuex States Undefined

So how did you set up your Vuex store, and how are you trying to set it. Show us some code. :)

Tomi left a reply on How To Print HTML Content From Database?

in your controller you have to pass the data to the blade:

    public function index()
    {
    
    $element =  Element::all();
        return view('your_blade_file_name', ['element' => $element]);
    }

Tomi left a reply on Multiple Uploads With Progress And Preview (problem With Identification)

Yes i would build any Object on the javascript side to track the image progress.

let d = new Date();
let n = d.getTime();

let uploadState = {
    n + '_my_image' : {
        'file_name' => 'my_image'
        'status' => 'uploading'
    },
    n + '_other_image' : {
        'file_name' => '_other_image'
        'status' => 'done'
    }
}

something like this. With each action you perform you can update this object. Vue offers functionality called Watcher you can track change of a variable, that might also come handy.

But this is just an idea. How you implement it is on you. :)

05 Oct
8 months ago

Tomi left a reply on Vue Is Not Showing Data On Blade Partial

How do you include the partial? Show us some more code.

Tomi left a reply on Create Models "on The Fly" Before Its Parent Model Is Saved

i would just put everything in a transaction and save the user first then save the array / collection of tutorships. If something fails just do a rollback so you dont have inconsistent database.

03 Oct
8 months ago

Tomi left a reply on Multiple Uploads With Progress And Preview (problem With Identification)

"Put your images in the upload-area" at this stage i would generate some ID key from the name and maybe timestamp when it was uploaded.

Tomi left a reply on Deleting/Updating A File Already Present On The Database

You make an ajax, or post request to your server hitting a specific url lie:

`user/{user}/image/delete``

this will then call the controller function deleteUserImage

public function deleteUserImage(User $user) {

   $user->image = '' ; // or set it to default image what ever
   $user->save();

    // then here you probably remove the file from your server  

   return response('success');
}
20 Sep
8 months ago

Tomi left a reply on Laravel Array Validation With Vue Components

@marufalom there is a rely good Video series for this topic (actually 3 videos).

Jeffry shows you how to make object oriented forms and also how to show the errors:

https://laracasts.com/series/learn-vue-2-step-by-step/episodes/19

But for looping trough array in javascript:

var array1 = ['a', 'b', 'c'];

array1.forEach(function(element) {
  console.log(element);
});
19 Sep
8 months ago

Tomi left a reply on Loop Json In Vue 2 Component

you can loop you object and create a new one:

let newObject = {};
$.each(object, function(index, value) {
    console.log(value);
        newOject.push({
            'value' : value.id,
            'text' : value.information
        })
}); 
14 Sep
9 months ago

Tomi left a reply on Checking If Laravel Model Property Is Set?

For me they are both set to null, not sure what your question is?

Do you mean if they where set to any value at some time?

Tomi left a reply on Laravel 5.7 - Js

It sounds like this is rather something you have to learn first.

Are you familiar with Laravel Mix? https://laravel.com/docs/5.7/mix

Try to set it up by your own first. Anyhow here is a quick rundown:

Import/require your phaser packase in the app.js. There are probably some instruction on the site of phaser to.

Setup laravel mix to copy your app.js from resource to public folder.

include the js file in your master layout or header blade.

10 Sep
9 months ago

Tomi left a reply on Correct Way To Install PhotoSwipe Gallery ?

you can tell mix from where to where it should copy files (images or what ever):

mix.copy('resources/assets/images', 'public/images');

your images are probably in under node_modules/photoswipe 

Tomi left a reply on Sorting By Human Readable Date When Using DataTables

Also you could just select the data in diffForHumans() and normal format, and tell datatables that when you click the sort field it should just sort by a different column.

Im happy you figured it out tho. :)

Tomi left a reply on Correct Way To Install PhotoSwipe Gallery ?

Probably something like this:

import PhotoSwipe from "photoswipe";
import PhotoSwipeUI_Default from 'photoswipe/dist/photoswipe-ui-default';

Tomi left a reply on Sorting By Human Readable Date When Using DataTables

If you are using Server-Side data source: https://datatables.net/manual/server-side

you can just send the column to the server for that is should be sorted.

If Your column is in the table i cant imagine that the sortBy() is not working.

If you are paginating the data you have tosortBy()->paginate().

07 Sep
9 months ago

Tomi left a reply on Common Methods, Data In Layout And Vue File Of Vue App?

If i understand correctly this sounds like a Job for https://vuex.vuejs.org/

If you already have looked into Vuex and its not what you need, you can try to make Bus on the window.

like : `window.myStore = {someData: '123'};``

then in your pages you have access: myStore.someData

Tomi left a reply on Comparing A Collection Within A Colection And Fetching The Result Of Inner Collection

intersect() returns the data presented in both collections:

$collection = collect(['Desk', 'Sofa', 'Chair']);

$intersect = $collection->intersect(['Desk', 'Chair', 'Bookcase']);

$intersect->all();

// [0 => 'Desk', 2 => 'Chair']

Tomi left a reply on Getting Vue To Move Category Depending On Category_id

ahhh html syntax error. You cant have a tr in a tr. This works for me fine:

<template>
    <div class="card-body">
        <table class="table">
            <thead class="thead-dark">
            <tr>
                <th scope="col">Active</th>
                <th scope="col">Title</th>
                <th scope="col">Edit</th>
                <th scope="col">Delete</th>
            </tr>
            </thead>

            <tbody>
            <tr v-for="(category, index) in categories" :class="getClass(category.category_id)">
                <td>
                    {{ category.title }}
                </td>

            <td v-if="(category.hasOwnPropery('parentCategory') && category.parentCategory.length > 0)" v-for="(child, indexChild) in category.parentCategory">
                {{ child.title }}
            </td>

            </tr>
            </tbody>
        </table>
    </div>
</template>

<script>

    export default {

        props: ['attributes'],

        data(){
            return {
                categories: this.attributes
            }
        },

        methods: {

            getClass(category_id){

                var parentClass = '';

                if(category_id === 0){
                    var parentClass = 'parent';
                }else{
                    var parentClass = '';
                }

                return parentClass;
            },
        },

        mounted() {
            console.log('Component mounted.')
        }
    }
</script>

Tomi left a reply on Getting Vue To Move Category Depending On Category_id

Post me your complete Vue component code please.

Tomi left a reply on Getting Vue To Move Category Depending On Category_id

are you in a blade.php file or a .vue file. If its a blade.php you have to tell Laravel to leave the bracets allone.

    <td>
        @{{ category.title }}
    </td>