Tomi

Full Stack Developer at Connex Marketing GmbH

Experience

16,290

7 Best Reply Awards

  • Member Since 9 Months Ago
  • 107 Lessons Completed
  • 0 Favorites

17th October, 2018

Tomi started a new conversation Laravel Nova Action Fields • 1 day ago

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?

8th October, 2018

Tomi left a reply on Vuex States Undefined • 1 week ago

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? • 1 week ago

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) • 1 week ago

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

5th October, 2018

Tomi left a reply on Vue Is Not Showing Data On Blade Partial • 1 week ago

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 • 1 week ago

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.

3rd October, 2018

Tomi left a reply on Multiple Uploads With Progress And Preview (problem With Identification) • 2 weeks ago

"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 • 2 weeks ago

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');
}

20th September, 2018

Tomi left a reply on Laravel Array Validation With Vue Components • 4 weeks ago

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

19th September, 2018

Tomi left a reply on Loop Json In Vue 2 Component • 4 weeks ago

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
        })
}); 

14th September, 2018

Tomi left a reply on Checking If Laravel Model Property Is Set? • 1 month ago

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 • 1 month ago

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.

10th September, 2018

Tomi left a reply on Correct Way To Install PhotoSwipe Gallery ? • 1 month ago

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 • 1 month ago

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 ? • 1 month ago

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 • 1 month ago

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

7th September, 2018

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

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 • 1 month ago

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 • 1 month ago

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 • 1 month ago

Post me your complete Vue component code please.

Tomi left a reply on Getting Vue To Move Category Depending On Category_id • 1 month ago

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 • 1 month ago

<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 .... • 1 month ago

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? • 1 month ago

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

Tomi left a reply on How To Format Date In Blade? • 1 month ago

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 • 1 month ago

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? • 1 month ago

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? • 1 month ago

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.

6th September, 2018

Tomi left a reply on Laravel 5.7 Undefined Index: App\Company • 1 month ago

@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 • 1 month ago

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 • 1 month ago

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 • 1 month ago

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

Tomi left a reply on Laravel 5.7 Upgrade, Observer Problem • 1 month ago

@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 • 1 month ago

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

1st September, 2018

Tomi left a reply on Vue CLI 3 And Laravel Backend • 1 month ago

@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?

31st August, 2018

Tomi started a new conversation Vue CLI 3 And Laravel Backend • 1 month ago

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.

27th August, 2018

Tomi left a reply on How To Use JQuery In Laravel 5.6 • 1 month ago

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 • 1 month ago

do you get any console error messages?

26th August, 2018

Tomi left a reply on Vue Component Not Initialized When Inserted Into The Page After The Page Load • 1 month ago

Is there a reason you are using jQuery?

You could just use v-if="showMyComponent" or v-show="showMyComponent"

Tomi left a reply on [Vue Warn]: Property Or Method "message" Is Not Defined On The Instance But Referenced During Render. Make Sure That This Property Is Reactive, Either In The Data Option, Or For Class-based Components, By Initializing The Property. See: Https://vuejs.org/ • 1 month ago

I have no idea what you want to achieve. But!

Just some minor tips:

1.If you are using Laravel i would put the Vue instance in the app.js and only use one Vue Instance.

2.You can delete that script part and add that to your vue instance.

const app = new Vue({
    el: '#app',
        data: {
        
                message: 'dsdsds'
       
        },
        mounted() {
            console.log('Upload component', this.message);
        }
});

also the template you dont need that..

  1. Third option would be to put all that script and template and the input in its own component and register it in the app.js

24th August, 2018

Tomi left a reply on Deleted_at Field In User Always Returning NULL • 1 month ago

Can you post your User model please?

23rd August, 2018

Tomi left a reply on Serverside Render VueJS - NO SPA - • 1 month ago

You might want to take a look at this: https://ssr.vuejs.org/#why-ssr

and also Nuxt.js :https://nuxtjs.org/

Tomi left a reply on Eager Loading Relationship • 1 month ago

@mercyware hmm you might try this, not sure tho, never used this kinde of Query :)


$query = Subject::doesntHave('class_subjects')
                ->orWhereHas('class_subject', function($query) {
                    $query->where('is_active', false)
                })->get();

your is_active is probably a Boolean.

Good luck. :)

Tomi left a reply on Hiding Https: In Input Text Value. • 1 month ago

Not sure why this happens, you can try escape html special chars. ´{{!! $url !!}}´

Tomi left a reply on Eager Loading Relationship • 1 month ago

$query = Subject::doesntHave('class_subjects')->get();

20th August, 2018

Tomi left a reply on How To Create Validation With Ajax? • 1 month ago

Well not sure if i understand you, but the validation will behave the same if you do and ajax or a normal post.

You can see the request in your Chrome Developer Tools -> Network Tab. In the response you will see the invalid fields.

You dont need that $request ajax part. ´´´´

public function store(SchoolRequest $request) { if($request->ajax()) { //code } }

´´´´

17th August, 2018

Tomi left a reply on Query Builder - Distinct Rows (with Multiple Columns) • 2 months ago

´$query->selectRaw('distinct(id)');´

14th August, 2018

Tomi left a reply on How To Use Vue Material In Laravel 5.6 ? • 2 months ago

You also need to add this to your master layout, or welcome blade or what ever its called

´´´´´´

CodeSandbox Vue Material

´´´´´´

Then you need to make an App.vue where you put all the Vue Material things. Also you could just try to add them to this blade. That should actually work.

Just put it in the app div.

´´´

My Title
  <md-app-drawer md-permanent="full">
    <md-toolbar class="md-transparent" md-elevation="0">
      Navigation
    </md-toolbar>

    <md-list>
      <md-list-item>
        <md-icon>move_to_inbox</md-icon>
        <span class="md-list-item-text">Inbox</span>
      </md-list-item>

      <md-list-item>
        <md-icon>send</md-icon>
        <span class="md-list-item-text">Sent Mail</span>
      </md-list-item>

      <md-list-item>
        <md-icon>delete</md-icon>
        <span class="md-list-item-text">Trash</span>
      </md-list-item>

      <md-list-item>
        <md-icon>error</md-icon>
        <span class="md-list-item-text">Spam</span>
      </md-list-item>
    </md-list>
  </md-app-drawer>

  <md-app-content>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Error quibusdam, non molestias et! Earum magnam, similique, quo recusandae placeat dicta asperiores modi sint ea repudiandae maxime? Quae non explicabo, neque.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Error quibusdam, non molestias et! Earum magnam, similique, quo recusandae placeat dicta asperiores modi sint ea repudiandae maxime? Quae non explicabo, neque.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Error quibusdam, non molestias et! Earum magnam, similique, quo recusandae placeat dicta asperiores modi sint ea repudiandae maxime? Quae non explicabo, neque.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Error quibusdam, non molestias et! Earum magnam, similique, quo recusandae placeat dicta asperiores modi sint ea repudiandae maxime? Quae non explicabo, neque.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Error quibusdam, non molestias et! Earum magnam, similique, quo recusandae placeat dicta asperiores modi sint ea repudiandae maxime? Quae non explicabo, neque.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Error quibusdam, non molestias et! Earum magnam, similique, quo recusandae placeat dicta asperiores modi sint ea repudiandae maxime? Quae non explicabo, neque.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Error quibusdam, non molestias et! Earum magnam, similique, quo recusandae placeat dicta asperiores modi sint ea repudiandae maxime? Quae non explicabo, neque.</p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Error quibusdam, non molestias et! Earum magnam, similique, quo recusandae placeat dicta asperiores modi sint ea repudiandae maxime? Quae non explicabo, neque.</p>
  </md-app-content>
</md-app>
´´´

30th July, 2018

Tomi left a reply on How To Return The Excel Download To Ajax ?? • 2 months ago

I would suggest to do a BLOB when downloading a file with ajax. In my case im using axios but that should not be any different to make with ajax.

        let laddaExportButton = Ladda.create(document.querySelector('.ladda-export-button'));
        laddaExportButton.start();
        laddaExportButton.setProgress(1);

        axios({
            url: '/download/path/to/excel',
            method: 'GET',
            responseType: 'blob',
            params: params
        }).then((response) => {
            const url = window.URL.createObjectURL(new Blob([response.data]));
            const link = document.createElement('a');
            link.href = url;
            link.setAttribute('download', page + '_' + moment(moment.now()).format("DD_MM_YYYY_HH_mm_ss") + '.xls');
            document.body.appendChild(link);
            link.click();
            laddaExportButton.stop();
        }).catch((error) => {
            laddaExportButton.stop();
        });

In my backend i have a lot of classes built around the download but in the end i just do this:

i just download the file like you do

resolve(Excel::class)->download($this, $fileName, $writerType ?? $this->writerType ?? null);
Edit Your Profile
Update

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