Tomi

at Connex Marketing GmbH

Experience

5,670

2 Best Reply Awards

  • Member Since 8 Months Ago
  • 36 Lessons Completed
  • 0 Favorites

20th August, 2018

Tomi left a reply on How To Create Validation With Ajax? • 2 days 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) • 4 days ago

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

14th August, 2018

Tomi left a reply on How To Use Vue Material In Laravel 5.6 ? • 1 week 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 ?? • 3 weeks 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);

24th July, 2018

Tomi left a reply on Boolean Status With Input Radio - Vue • 4 weeks ago

you have to define a value. Or whats the point of 3 radio buttons?

Tomi left a reply on Stuck With Pivot Table.... • 4 weeks ago

if you want the data from the pivot table you have to define it:

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

Tomi left a reply on Problem In Retrieving The Data In View.blade Laravel • 4 weeks ago

not sure why, but if you open the Chrome Dev Tools you can go to network tab and see if the field value is submited to the server. F12 on Windows i think. on Mac (option + command + i);

Also im not a real fan of this helper functions and never rly used one (doesnt mean its bad).

But i would just try to submit my data with a simple input form and see what happens.

23rd July, 2018

Tomi left a reply on Profile Changes Approve/reject - Keep The Current As Active • 4 weeks ago

Im not sure about such a package.

But i would just create something like a tbl_profile_change_request Table.

And whenever the user performs an update on the User model, i would write the other table with then given data.

You can make a User observer for example and listen to it in the updating function, then prevent the actual model update.

https://laravel.com/docs/5.6/eloquent#observers

Tomi left a reply on Problem In Conversion To Pdf In Laravel • 4 weeks ago

@AbdulBazith also you might want to accept Sanpeys answer :)

Tomi left a reply on How To Convert Date Fields To Timestamps And Substract Them? • 4 weeks ago


var task = {{ $task }}

or if its an array you can also:

  var task = @json($task);

Tomi left a reply on Problem In Retrieving The Data In View.blade Laravel • 4 weeks ago

i think your problem is with the loadView

Your are doing

    $pdf=PDF::loadView('Sales_details.view1',['sales'=>$sales],['date'=>$request->search_date]);

And i think its supposed to be:

    $pdf=PDF::loadView('Sales_details.view1',
    [
    'sales'=>$sales,
    'date'=>$request->search_date
    ]);

Tomi left a reply on How To Convert Date Fields To Timestamps And Substract Them? • 4 weeks ago

Well you could calculate this in the backend:

{{$task->startDate->diffInRealHours($task->stopDate)}} this could be your valuenow

not sure what you max value is.

this would return this difference in hours.

Also if you want to do something on the frontend with dynamically updating your blade you might want to look into Moment.js

https://momentjs.com/

var a = moment([2007, 0, 29]);
var b = moment([2007, 0, 28]);
a.diff(b) // 86400000

Tomi left a reply on Problem In Retrieving The Data In View.blade Laravel • 4 weeks ago

What do you get when:

$sales = Sales_details::where('date',$request->date)->get()
dd($sales);

Tomi left a reply on How To Convert Date Fields To Timestamps And Substract Them? • 4 weeks ago

Laravel is using Carbon:

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

You can convert both dates and then use diff

Also if you want the substraction of two dates you can use sub functions:

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

21st July, 2018

Tomi left a reply on Problem In Conversion To Pdf In Laravel • 1 month ago

Cant see any problem at first glance, i would add this to the start of the page:

<!DOCTYPE html>

and maybe start to debug when the table gets broken, start with showing only 1 row, then slowly build up the table.

Tomi left a reply on $vm0.$children Return 0 Element But There Has 3 Children • 1 month ago

In the Lession #11 vm$0 is the Tabs. On your Picture i can see that vm$0 is "Tab"

add this to your "tabs" component to see the children:

mounted() {
    console.log(this);
}

20th July, 2018

Tomi left a reply on Getting Collection Data From Database Suitable For Showing In Html Table • 1 month ago

I can think of 2 possibilities.

  1. Your table rows are the Items with properties and category properties in columns.

    for this you have to start from the items: new Item()->with('categories', 'itemProperties')

  2. Go trough the categories, and make detail rows, for the items that belong to the category.

    Category()->with('items', 'categoryProperty')

Tomi left a reply on Can I $emit From A Blade To A Vue Component? • 1 month ago

You do usually pass data via properties from blade to a Vue component.

Vue.component('blog-post', { // camelCase in JavaScript props: ['postTitle'], template: '

{{ postTitle }}

' })

https://vuejs.org/v2/guide/components-props.html

Tomi left a reply on $vm0.$children Return 0 Element But There Has 3 Children • 1 month ago

Can you please provide your HTML and Vue code aswell please?

24th May, 2018

Tomi started a new conversation Prevent Laravel From Setting Updated_at When Creating • 2 months ago

Is there a way to prevent Laravel from setting the updated_at timestamp when i create a new entry in the Database?

Right now how it works when i create a new entry both created_at and updated_at are the same value.

Not sure if i like this behavioir, i woul much rather like if the uodate timestamp is NULL at inserts.

But thats just me , anyone knows whats the reasoning behinde setting updated_at when its an insert?

2nd May, 2018

Tomi left a reply on Request Rule Is Not Catching The Errors • 3 months ago

Yap i do use the ActionRequest. Cuase i get the undefined index error for prm_action_type_id. This is realy strange.

26th April, 2018

Tomi started a new conversation Request Rule Is Not Catching The Errors • 3 months ago

namespace App\Http\Requests;

class ActionRequest extends Request { protected $dates = [ 'timestamp', 'timestamp_end' ];

/**
 * Get the validation rules that apply to the request.
 *
 * @return array
 */
public function rules()
{
    $rules = [
        'timestamp' => 'required',
        'user_id' => 'required',
        'name' => 'required',
        'prm_action_type_id' => 'required'
    ];

    return $rules;
}

public function all($keys = null)
{

    $result = parent::all($keys);

    $types = app('\App\Repositories\System\Action\TypeRepository');

    $actionType = $types->find($result['prm_action_type_id']);

    if (!isset($actionType->appointment) && array_key_exists('timestamp_end', $result)) {
        unset($result['timestamp_end']);
    }

    return $result;
}

}

So i expected that if i have aRequest Class with rules and i override the all function the Request gets validated when i call ->all(). Instead i get undefined index prm_action_type_id (that is ok, cause i didnt even sent it to the server, but i expected to be catched by the Rules.)

I think i got here something wrong?

18th April, 2018

Tomi started a new conversation JavaScript Class Getter/Setter • 4 months ago

is there a way to listen for a property call on a JavaScript Class

for example when i go something like this:

myForm = new Form();

myForm.name = 'Name'; -> when i set the name i dont only want to set the property but i also want to update my Vuex store. Same thing with get i would like to read from Vuex store.

I knoew there are thins like Proxy but for this i need to wrap my Class with a Proxy object. Not so sure if i like this.

module.exports = new Proxy(new Form({}), { get (receiver, name) { console.log('getting property from Vuex Store'); } }); What i need is something like this:

module.exports = class Form {

//this should be triggered when form.something get(property) { return this[property]; }

//this should be triggered when from.something = 'something' set(property, value) { return this[property] = value; } }; it there a best practice for this?

10th April, 2018

Tomi left a reply on Failed To Mount Component: Template Or Render Function Not Defined. • 4 months ago

Hi axtg,

this is my new account.

Sadly it is not possible to use inline-template in another one, well this is what i figured out.

Actually Jeff does some Vue refactoring in this lession https://laracasts.com/series/lets-build-a-forum-with-laravel/episodes/32

and the next one i think also, and somewhere he is getting the same error cause he trys to use inline-template inside another one. So he is actually refactoring the blade templae to a Vue file.

28th March, 2018

Tomi left a reply on Extract A Vue Component As Npm Package • 4 months ago

Thx for the hint gonna have a look!

26th March, 2018

Tomi left a reply on Extract A Vue Component As Npm Package • 4 months ago

@ivanv Hi

Im looking for the same solution. Also found that tutorial of yours. What i dont understand is how do i know what devDependecies do i need, and also how can i test my component.

Tryd to use vue-cli templates but thos are like the Laravel enviroment, made for full projects.

Did you manage to find a good tutorial yet?

Tomi started a new conversation Create And Publish Vue Component To NPM • 4 months ago

Anyone got a detailed Guide on how to develope and publish Vue components to NPM.

I know a fair bit about how to create and include Vue components in the Laravel Framework enviroment.

Now i would also like to know how to develope standalone vue components wich then i can npm install in my other Laravel projects.

I toke a look into vue-clt and the vue-templates they provide, but thats more of a full project developement setup.

Also found this small Guide https://vuejsdevelopers.com/2017/07/31/vue-component-publish-npm/

But im not sure how to use this to actually develope the component.

Tomi left a reply on Is There A Way To Make DB::table() Return Carbon Date • 4 months ago

I feel like sometimes i reach the limit of Eloquent and im just better of going DB way. Like doing more complex joins also aliasing tables. Filtering data on joined tables so on.

As my query is behinde a Repository layer i can parse all my data fileds in the all() or paginate() function of my Repo.

21st March, 2018

Tomi left a reply on Is There A Way To Make DB::table() Return Carbon Date • 5 months ago

thats what i was afraid of. :(

Tomi started a new conversation Is There A Way To Make DB::table() Return Carbon Date • 5 months ago

Hi,

just a quick question cause im unable to find an answer.

Is there a way to make DB::table() return a Carbon date like the Eloquent models. Instead of a string.

1st March, 2018

Tomi started a new conversation NewQuery, ToBase, GetQuery • 5 months ago

Can some one explain me the difference between this 3 functions? Every single one of them is returning the same Query as it seems. Is there a benefit to use one over the other?

$model->where('prm_partner_id', 1)->newQuery()->toSql();
$model->where('prm_partner_id', 1)->toBase()->toSql();
$model->where('prm_partner_id', 1)->getQuery()->toSql();

select * from "TBL_PRM_CONTRACT" where "PRM_PARTNER_ID" = ?
select * from "TBL_PRM_CONTRACT" where "PRM_PARTNER_ID" = ?
select * from "TBL_PRM_CONTRACT" where "PRM_PARTNER_ID" = ?

17th January, 2018

Tomi left a reply on Is There A Way To Extend The Query Builder? • 7 months ago

@martinbean So what i actually did now is a simple class where i create a query and when i call a function this query get returned and it can be filtered by the filter class then selected.

namespace App\Query;


use Illuminate\Support\Facades\DB;

class Contract
{

    protected $query;

    public function __construct()
    {
        $this->initQuery();
    }

    public function initQuery()
    {
        $this->query = DB::table('tbl_prm_contract');

    }

    public function getQuery()
    {
        return $this->query;
    }

}

In the Controller:

    public function getAll(ContractFilter $filter ,\App\Query\Contract $contract)
    {

        $this->contractRepo = new ContractRepository($contract->getQuery());

        return $this->contractRepo
            ->filter($filter)
            ->advancedFilter(\request()->get('data'), $filter)
            ->getAll();
    }

16th January, 2018

Tomi left a reply on Is There A Way To Extend The Query Builder? • 7 months ago

I have a big data structure with many joins over different tables. Where i think eloquent would not be enough.

Also i read somewhere that Eloquent and joins arent the best friends.

Tomi started a new conversation Is There A Way To Extend The Query Builder? • 7 months ago

I would like to extend the Query Builder so i have my own raw Query builder class, that i can filter down. I tryd to do it like this:

namespace App\Query;

use Illuminate\Database\ConnectionInterface;
use Illuminate\Database\Query\Builder;
use Illuminate\Database\Query\Grammars\Grammar;
use Illuminate\Database\Query\Processors\Processor;

class Contract extends Builder
{

public function __construct(ConnectionInterface $connection, Grammar $grammar = null, Processor $processor = null)
    {
        parent::__construct($connection, $grammar, $processor);

        $this->from('tbl_prm_contract');
    }

}

Then in my controller:

    public function getAll(ContractFilter $filter ,\App\Query\Contract $contract)
    {

        error_log($contract->where('prm_partner_id' , '=', 1)->toSql());

        error_log($contract->where('prm_partner_id' , '=', 1)->get());

    }

if i return the query i get this:

select * from "tbl_prm_contract" where "prm_partner_id" = ?

this is fine the table and field is correct. Problem is when i try to get the data and execute the query it fails with the error: Table or view notfound.

"message": "Error Code    : 942\nError Message : ORA-00942: Tabelle oder View nicht vorhanden\nPosition      : 14\nStatement     : select * from \"tbl_prm_contract\" where \"prm_partner_id\" = :p0 and \"prm_partner_id\" = :p1\nBindings      : [1,1]\n (SQL: select * from \"tbl_prm_contract\" where \"prm_partner_id\" = 1 and \"prm_partner_id\" = 1)"

Any one got an idea?

Tomi started a new conversation For Large Querys And Filtering, Still Use Eloquent Models? • 7 months ago

Hi,

I am creating a Filter so the users can filter down Contracts then show it in a Table.

They need to have option to Filter Fields that are in different tables, goin through many joins.

user needs to get all contracts with the price of "50" located in service_charge

contracts->partner->service->service_charge

Is it still preferable to use the Contract Model with that many joins?

Or sould just Create Query_Contract class, with a DB:: query in it and fillter that one down?

Also i am using a "frontend query builder" and sending this json to the server to get the needed data:

{ "condition": "AND", "rules": [ { "id": "user_id", "field": "user_id", "type": "select", "operator": "equal", "value": 203 } ] }

10th January, 2018

Tomi started a new conversation Default Value Is Ignored When Makeing Db Insert. • 7 months ago

Hi,

I am calling a

Contract::create($request->all())

in my Contract model i defined that

protected $attributes = [
    'creation_status' => self::CREATION_STATE_NEW,
    'status' => self::CONTRACT_STATUS_NEW
];

status should have a default value of 1.

In the request i send to server the status is not set so its {'status': ''}

It seems that laravel is ignoreing the default value. I get a null in the DB.

Edit Your Profile
Update

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