janokary

janokary

Member Since 4 Years Ago

Sykia, Xylokastro

Experience Points 17,415
Experience Level 4

2,585 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 300
Lessons
Completed
Best Reply Awards 1
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.

14 Jun
1 year ago

janokary left a reply on Calculate Net Given A Gross Value And Vice Versa

It would be nice if you do. Thanks in advance.

janokary left a reply on Calculate Net Given A Gross Value And Vice Versa

Yes, that would be the first thing to do but only after deciding if the main idea in this code is good. I mean, would it be better, to use computed properties instead of watching data and if this so how would this could be done?

janokary started a new conversation Calculate Net Given A Gross Value And Vice Versa

Hi, I want to calculate the gross value given a net price and vice versa. What I have done is this: https://jsfiddle.net/janokary/mv0de94r/ Can you think of anything better or more slick?

30 Mar
2 years ago

janokary started a new conversation Markdown Mailables Translation

Hi, how can I set the language for an email written in markdown?

06 Feb
2 years ago

janokary started a new conversation ForceScheme Or ForceSchema In Laravel 5.4

I upgraded from 5.3 to 5.4 It seems that when you want to Render all URLs with https \URL::forceSchema('https'); is now \URL::forceScheme('https'); with an "e" instead of "a" in forceScheme

https://laravel.com/api/5.0/Illuminate/Routing/UrlGenerator.html#method_forceSchema vs https://laravel.com/api/5.4/Illuminate/Routing/UrlGenerator.html#method_forceScheme

can you confirm that?

30 Nov
2 years ago
22 Nov
2 years ago

janokary left a reply on Alter Table Change Field To LONGTEXT;

Thank you for your suggestions @lindstrom.

janokary left a reply on Alter Table Change Field To LONGTEXT;

@lindstrom. Actually what I was trying to do is to change a text field (not string) to longText.

janokary left a reply on Alter Table Change Field To LONGTEXT;

Yes dbal is allready inscluded.

janokary started a new conversation Alter Table Change Field To LONGTEXT;

Hello I tried to change

   Schema::table('table_name', function ($table) {
    $table->longText('column_name')->nullable()->change();
  });

but It didn't work so I changed it with tinker: DB::statement('ALTER TABLE tabel_name CHANGE column_name column_name LONGTEXT;');

Is this a bug or something?

16 Nov
2 years ago

janokary left a reply on Where Are You All From?

Sykia korinthia, Greece

31 Aug
2 years ago

janokary left a reply on Can't Setup Elixir Properly To Compile Scss, .vue Files On L5.3. Gulp Watch Not Triggering On Changes.

Ok this seems to do the trick but temporally . It creates the files in public directory but server at 3000 is extremely slow and memory consuming like most of the people (including me) state in the later comments. ... and it often crash.

16 Jul
2 years ago

janokary started a new conversation Select Only Some Columns From A Nested Query

I have a nested query where in addition to what I have now ( and works) I also want to get only some columns from user

    $users = User::whereHas('contacts', function ($query) use ($phonenumber) {
                          $query->where('contact', '=', $phonenumber );
                        })
                ->with([
                  'addresses' => function($query) {
                                           $query->select('*');
                                  },
                  'contacts' => function($query) {
                                            $query->select('id', 'user_id', 'type', 'contact' );
                                  }
               ])
               ->get();

I tried adding

->select('name')

before get() but when I do that I get only the name and nothing else e.g. [{"name":"janokary","addresses":[],"contacts":[]}]

Any ideas?

14 Jul
2 years ago

janokary left a reply on Split Mutations.js Into Smaller Files

Yes @evanb2 . This is the case.

13 Jul
2 years ago

janokary left a reply on Split Mutations.js Into Smaller Files

@evanb2 splitting the state into modules is the proper way to do it. I am dealing with a situation where there is reusable code in mutations.

09 Jul
2 years ago

janokary left a reply on Split Mutations.js Into Smaller Files

Maybe this is an overkill but it is a solution: using jquery from this example ( http://goo.gl/3rOvIQ ) I splitted my original mutations.js into smaller files and then in store.js I did this:

import $ from 'jquery';
import { mutations1 } from './mutations1'
import { mutations2 } from './mutations2'

var mutations = $.extend({}, mutations1, mutations2);
...

janokary started a new conversation Breakdown Mutations.js Into Smaller Files

How do I break down mutations.js when using vuex ?

into smaller parts? I am using laravel's elixir.

so what I have now is mutations.js:

export const mutations = { FUNCTION1 (state) { }, FUNCTION2 (state) { }, FUNCTION3 (state) { }, }

store.js:

import Vue from 'vue' import Vuex from 'vuex'

import { state } from './modules/state'

import { mutations } from './mutations'

Vue.use(Vuex)

export default new Vuex.Store({ state: { data state }, mutations })

janokary left a reply on Facebook Business Pages - Users: Schema For Privileges And Likes

@usama.ashraf I think that this is what I want, but how do I define and access 'user_page_likes' model?

janokary left a reply on Facebook Business Pages - Users: Schema For Privileges And Likes

@bobbybouwmann No I do not need to use polymorphic relations. The only relations are those I described at my original question. So how do I build this like system apart from my ACL system?

janokary left a reply on Facebook Business Pages - Users: Schema For Privileges And Likes

I would rather not put 'likes' in my 'page_user' pivot table, because this could affect my ACL strategy. I should have to define that someone that simply likes the page cannot have any other rights on the page.

janokary started a new conversation Facebook Business Pages - Users: Schema For Privileges And Likes

Hi guys I am building a facebook like schema where a user can have a roll on a business page e.g. admin or editor or moderator. I understand that this could be defined using pivot tables so we have:

  1. table users
  2. table pages
  3. table page_user where we can define an extra field 'privilege' and so we will have
public function pages()
{
      return $this->belongsToMany('App\User')->withPivot('privilege')->withTimestamps();
}

and

public function users()
{
      return $this->belongsToMany('App\Page)->withPivot('privilege')->withTimestamps();
}

Now, how can i define the case where a user simply likes a page? ( this is also a many to many relation ) Do a have to create another pivot table? and if so how do I do that?

28 Jun
2 years ago

janokary left a reply on Forcing HTTPS Routes On Laravel 5.2

No the route works fine either way when it is called directly e.g. http://domain.com/something/else or https://domain.com/something/else or http://domain.com/something/else/ or https://domain.com/something/else/

but when I call with jquery ajax this route /something/else/ defaults to http://domain.com/something/else/ (and the browser cut it) So I striped the trailing slash and now it works /something/else -> https://domain.com/something/else/

see here a question from 2012 http://stackoverflow.com/questions/13054842/jquery-ajax-not-using-https

27 Jun
2 years ago

janokary left a reply on Forcing HTTPS Routes On Laravel 5.2

Ok, This is crazy @bashy . The trailing slash was the problem. Take a look here: http://stackoverflow.com/questions/13054842/jquery-ajax-not-using-https

janokary left a reply on Forcing HTTPS Routes On Laravel 5.2

$.ajaxSetup({
headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }
});

$.ajax({
url: url,
type: type,
headers: { 'X-CSRF-Token': $('input[name="_token"]').val() },
async: async,
cache: false,
data: data,
success: function(data) {
result = data;
}
});

Url is relative. This works in some route and some other not. When I access the routes directly with https there is not problem.

janokary left a reply on Forcing HTTPS Routes On Laravel 5.2

Hi @bashy. Some routes are always ok (served by https) and some other always served by http. I make those requests from vue.js using jquery ajax. Could this be the problem?

26 Jun
2 years ago

janokary left a reply on Forcing HTTPS Routes On Laravel 5.2

Yes @bashy. That could solve my problem and I think is a preferred solution. But, is there a work around with this one? I also like it because I might need load balancing or proxy.

janokary started a new conversation Forcing HTTPS Routes On Laravel 5.2

Hi I want to only use https in my web site.

I followed the instructions here http://www.jeffmould.com/2016/01/31/laravel-5-2-forcing-https-routes-when-using-ssl/ with success but there are two cases that this doesn't work.

  1. After login I redirect to a non secure page.

  2. in routes like this one:

     Route::get('timezones', 'Api\Utilities\[email protected]');
    

    public function timeZones() { $timeZones = \DateTimeZone::listIdentifiers(); return $timeZones; }

I use:

  • laravel v5.2.31
  • on heroku
  • php (7.0.7)
  • ext-mbstring (bundled with php)
  • apache (2.4.20)
  • nginx (1.8.1)

Any ideas?

08 Jun
2 years ago

janokary left a reply on ACL Policies Not Working Properly

I had the same problem. I realised that I had a typo in the model class where class name began with a small letter instead of a Capital. Capitalising the first letter in the model class solved the problem

janokary left a reply on Laravel 5.11 Authorization Doesn't Read Policies

I had the same problem. I realised that I had a typo in the model class where class name began with a small letter instead of a Capital. Capitalising the first letter in the model class solved the problem

03 Apr
3 years ago

janokary started a new conversation Pusher With Vue

I set up an event that I want to broadcast using pusher. Everything seams to be ok. When I trigger the event I can see that the message is send to pusher.com through the "test-channel" (watching Total messages sent today in pusher dashboard)

public function broadcastOn()
{
  return ['test-channel'];
}

In my app.js ( I use vue ) I have a ready function for the subscription.

  ready: function () {
    this.pusher = new Pusher('--my public key--', {
      cluster: 'eu',
      encrypted: true
    })
    this.pusherChannel = this.pusher.subscribe('test-channel');

    this.pusherChannel.bind('App\\Events\\EventTookPlace', function(data) {
        console.log('message received');
        console.log(data);
    }.bind(this));
  }

I can also see that the client is also subscribed to that channel but I don't get 'message received' when the event is triggered.

I use

  • Laravel 5.2.28,

  • pusher/pusher-php-server v2.3.0

  • pusher-js ^3.0.0

  • vue 1.0.16

and also browserify and elixir.

Does this has to do with the fact that my is in an separate file and not inline in the blade file?

23 Feb
3 years ago

janokary left a reply on Vue.js Transition For Loading Data

Very nice. @craigwebster you need to bind(this) in order to alter this.loading in the response function.

new Vue({
   data: {
    loading: false
    },
    ready: function() {
    this.loading = true;
      // GET request
      this.$http({url: '/someUrl', method: 'GET'}).then(
      function (response) {
          // success callback
          this.loading = false;
      }.bind(this),
      function (response) {
          // error callback
      });
    }
})
15 Feb
3 years ago

janokary left a reply on Vuex, Initializing Data In App State

I think @camerongrant suggestion is what I was looking for, but @jimmck also improves my current thought. Thank you both @camerongrant and @jimmck.

09 Feb
3 years ago

janokary started a new conversation Vuex, Initializing Data In App State

Hi all, I use vuex in little project of mine. My problem is on how to initialise the 'app state' by getting data from Laravel backend. http://vuex.vuejs.org/en/data-flow.html What I am doing now (and works) is before

const state = {
 count: 0
}

to make an ajax call

$.extend ({
      getValues: function(url) {
          var result = null;
          $.ajax({
            url: url,
            type: 'get',
            async: false,
            cache: false,
            success: function(data) {
                result = data;
            }
          });
      return result;
      }
});
const initialCountStatus = $.getValues("/checkCounter");

and then set

const state = {
 count: initialCountStatus
}

As, I said this works fine, But setting async: false is not recommended and actually depreciated. What would be your approach in this?

07 Feb
3 years ago

janokary left a reply on Laravel 5.2. Login With Ajax Form

So, to override this vendor method properly I wrote it in app/Http/Controllers/Auth/AuthController.php ( and made use of Illuminate\Http\Request ).

janokary left a reply on Laravel 5.2. Login With Ajax Form

I use vue-resource that is waiting for the proper response header. So if you give a wrong email you won't get an error response but success. Changing this ( vendor/laravel/framework/src/illuminate/Foundation/Auth in AuthenticatesUsers.php ) solved my error, but I have to write another class override class to just override this one.

janokary started a new conversation Laravel 5.2. Login With Ajax Form

I use laravel 5.2 build in auth, but when in the login form I use ajax. When I post something that is not valid according to the validator I get a 422 response. Fine. But the email or the credentials are not right I don't. So what I did is in vendor/laravel/framework/src/illuminate/Foundation/Auth in AuthenticatesUsers.php and I altered the

protected function sendFailedLoginResponse(Request $request)
{
    return redirect()->back()
        ->withInput($request->only($this->loginUsername(), 'remember'))
        ->withErrors([
            $this->loginUsername() => $this->getFailedLoginMessage(),
        ]);
}

to

protected function sendFailedLoginResponse(Request $request)
{
  if ($request->wantsJson()) {
    return response([
      'ok' => false,
      'success' => false,
      'message' => $this->getFailedLoginMessage()
    ],422);
  };
    return redirect()->back()
        ->withInput($request->only($this->loginUsername(), 'remember'))
        ->withErrors([
            $this->loginUsername() => $this->getFailedLoginMessage(),
        ]);
}
17 Jan
3 years ago

janokary left a reply on Constraining In Nested Eager Loading

Thank you @pmall this is what I needed. Strange structures can always occur.

15 Jan
3 years ago

janokary left a reply on Constraining In Nested Eager Loading

@pmall, in your query the constrain is in the langs table.

$pages = Page::with(['pagedetails.langs' => function($query){ $query->where('code', '=', 'en'); }])->get();

So you get every ‘page’ with ‘pagedetails’ and and the corresponding langs where code=’en’

Now, what I want is, for each Page I to fetch all pagedetails ordered by slug (and then the corresponding pagedetails)

orderBy('slug', 'desc');

or another query would be for each Page I to fetch all pagedetails that have slug like foo% (and then the corresponding pagedetails)

where('slug', 'like', 'foo%')

So in those two situations the constrain is not in the first table ‘pages’ nor in the last ‘langs’ it is in the middle table ‘pagedetails’

14 Jan
3 years ago

janokary left a reply on Constraining In Nested Eager Loading

@pmall, What if we want to make a constrain in your query

$pages = Page::with(['pagedetails.langs' => function($query){
  $query->where('code', '=', 'en');
}])->get();

But in pagedetails not langs for instance:

orderBy('slug', 'desc');

or

where('slug', 'like', 'foo%')

I am stack in a situation like that

06 Jan
3 years ago

janokary left a reply on Retrieving A Many To Many To Many Reletion

I found it. It is

user->with(['books.tags'])->get();

Nested Eager Loading https://laravel.com/docs/5.1/eloquent-relationships#eager-loading

janokary left a reply on Retrieving A Many To Many To Many Reletion

@rohitkhatri Each book can have many tags, it is an one to many relation (in this case)

janokary left a reply on Retrieving A Many To Many To Many Reletion

Actually, I do have establish all proper relations in my models. So, 

In Users I have:

public function Books(){
  return $this->belongsToMany('App\Book');
}

In Books I have:

    public function users()
    {
        return $this->belongsToMany('App\User');
    }

    public function tags()
  {
     return $this->hasMany('App\book');
  }

and in tags I have:

    public function book()
  {
     return $this->belongsTo('App\book');
  }

I should finally mention that, there is also a pivot table book_user. I now want to make this query with eloquent.

janokary started a new conversation Many To Many To Many

Hi , I have a user that has (many to many) books and each book can have many tags. I want to retrieve one specific user's books that have at least one tag like this:

book1 -> tag1
      -> tag2
book2 -> tag3
       ->tag2