Tomi

Tomi

Full Stack Developer at Connex Marketing GmbH

Member Since 11 Months Ago

Experience Points 25,960
Experience
Level
Lessons Completed 201
Lessons
Completed
Best Reply Awards 7
Best Answer
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.

29 Nov
2 weeks 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
2 weeks 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
3 weeks 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
1 month 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
1 month 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
1 month 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
1 month 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
2 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
2 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
2 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
2 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
2 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
3 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
3 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
3 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>

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

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

Still now quit sure what you are trying to do but this could be one approach to check if there is a parent and then run trough the childs. v-if

Tomi left a reply on First Laravel Project ....

You should take a look at how Laravel handles assets. Also there is Laravel mix:

https://laravel.com/docs/5.6/mix

You just need to tell laravel mix from where it should take your js/(sass or less) and then it compiles it down using webpack behinde the scene.

Then you have an app.js and app.css files you can simply include. In your view.

Tomi left a reply on Is There A Way To Format Money In Blade?

Sure it has quit a lot config options. Result: $ 0.20

Tomi left a reply on How To Format Date In Blade?

Hmm thats a bummer. You could use something like moment.js, but thats also a Javascript library. Im not sure of there is a masking function in laravel.

Maybe you could write your own directive and call it something like:

{{ @dateFormat(post.published_at|date("m/d/Y")) }}

Tomi left a reply on Creating A Loop In Vue That Checks The Tr

You can do it by Vues class binding:

https://vuejs.org/v2/guide/class-and-style.html

<div v-bind:class="{ active: category.category_id }"></div>

Tomi left a reply on How To Format Date In Blade?

If you get your date from a Model, then it is a Carbon Object, and you can use all the Carbon functionalitys

https://carbon.nesbot.com/docs/#api-humandiff

For example:

{{post-publishdate_at->->diffForHumans();}}

Tomi left a reply on Is There A Way To Format Money In Blade?

I usually use http://openexchangerates.github.io/accounting.js/

and pass the informatio it needs from the server like what currency it should be formated, but you can store that on the frontend side aswell.

06 Sep
3 months ago

Tomi left a reply on Laravel 5.7 Undefined Index: App\Company

@Classified haha, happened also to me today.

Here is an issue, thats actually not considered an issue even tho it breaks all apps that are calling boot without the parent.

https://github.com/laravel/framework/issues/25455

Tomi left a reply on Laravel 5.7 Undefined Index: App\Company

And your Company model also not using any Boot functionality ?

Could you please post a more detailed error message?

The part above is only where the error starts.

You might want to remove all the traits you are using to be sure the error has nothing to do with one of your packages.

use Notifiable, HasRoles, SoftDeletes;

Tomi left a reply on List Pivot Table Data

I know there is a withPivot function:

return $this->belongsToMany('App\Role')->withPivot('column1', 'column2');

Not sure if i understand your problem correctly or if you an apply this.

https://laravel.com/docs/5.6/eloquent-relationships

Tomi left a reply on Laravel 5.7 Undefined Index: App\Company

Are you registering something on your models Boot method, like ab Observer?

Tomi left a reply on Laravel 5.7 Upgrade, Observer Problem

@qiutuleng thats working fine, do you have any idea why did that work before and now of a sudden it isnt?

Tomi started a new conversation Laravel 5.7 Upgrade, Observer Problem

Hi,

for some reason after upgrading to Laravel 5.7 grom 5.6 i cant register Observers like this anymore:

class Partner extends Model
{
    /**
     * disabled searchable trait, because there is no elastic search cluster available yet.
     */
    use Searchable;
    use ObservantTrait;

    public static function boot()
    {
        static::observe(new PartnerObserver());
        parent::boot();
    }

I get a Fatal Error saying that there is an Undefined Error:

   /www/my-project/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php

   protected function initializeTraits()
    {
        foreach (static::$traitInitializers[static::class] as $method) {
            $this->{$method}();
        }
    }
01 Sep
3 months ago

Tomi left a reply on Vue CLI 3 And Laravel Backend

@bobbybouwmann thank you for the suggestions, it actually helped a lot, i think i will stick with 1 project, cause it will be the first SPA i am going to create.

Also it will be probably easyer to configure my Docker nginx to just root to laravels index.php as localhost. :)

Just one more question if you dont mind. Right know when im doing some Vue stuff in a multipage application and lets say i do some post/get i usually just use routes like this:

axios.get('/users/5'); and this would look for the path in the web.php Route::resource('users', 'UserController');

Cause my views (blade/vue or what ever) are in the same Project directory.

So what is the approach when they are separated in two directorys? Do i have to make a full path call every time i fetch or post some data:

axios.get(https://my-website.com/users/5) and in development the same with localhost?

31 Aug
3 months ago

Tomi started a new conversation Vue CLI 3 And Laravel Backend

Hi,

Im looking for some Tutorials where an SPA is built utilising VueCLI 3 and then Laravel serves as a backend.

Or is there realy no reason to separate them in two parts and use VueCLI if i already got Laravel.

I mean i could just do everything in Laravel and put the whole frontend in the recource folder, and just do my SPA there, starting out in the app.js.

Also would probably make the deployment easyer.

Is there any best practice, how do you guys aproach such things ?

  1. Two seperate Apps -> /www/vue-spa, /www/laravel-api
  2. Single App ->/www/vue-laravel-app

open for suggestions.

27 Aug
3 months ago

Tomi left a reply on How To Use JQuery In Laravel 5.6

You can see the javascript errors if you open chrome dev tools and then refresh the page , or click the button.

Tomi left a reply on How To Use JQuery In Laravel 5.6

do you get any console error messages?