hajrovica

hajrovica

Member Since 3 Years Ago

Experience Points
35,590
Total
Experience

4,410 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
273
Lessons
Completed
Best Reply Awards
13
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 8
35,590 XP
27 Aug
3 weeks ago

hajrovica left a reply on Save Views With Executed Javascript For Later Use

@voidscholar can you share what solution you have found ?

29 Apr
4 months ago

hajrovica left a reply on Getting Fatal Errors In Core Of Laravel

did you do update or something ?

maybe this will help missing argument 1 ...

hajrovica left a reply on Laravel Like Not Working

i am not sure what but when we give a short string of characters will search. It gives the code means, but it is logical that larger string will return smaller set of results or none whit "LIKE" query, you are sure that "large string" actually can be found in "nazwa" field ?

20 Apr
5 months ago

hajrovica left a reply on Cannot Connect To Database With Docker And Pdo_mysql In Laravel

@MARCOSDIPAOLO - i thought you are asking for running artisan commands from terminal :)

hajrovica left a reply on Cannot Connect To Database With Docker And Pdo_mysql In Laravel

hmm not directly - there is a way to go around by making custom command in your site

containing something like

COMPOSE="docker-compose -f docker-compose.$COMPOSE_FILE.yml"

if [ $# -gt 0 ];then

    if [ "" == "art" ];then
      shift 1
      $COMPOSE run --rm $TTY \
        -w /var/www/html \
        app \
        php artisan "[email protected]"

this is extensively explained in shipping docker course but a gist is that you do docker compose run command by calling ./develop art route:list command will see that first arg is art then strip it and run php artisan with rroute:list (though in my example i am using image called app for you it would be web) I hope this kinda rushed info makes sense ?

hajrovica left a reply on Cannot Connect To Database With Docker And Pdo_mysql In Laravel

@marcosdipaolo

can you try in your .env file DB_HOST=mysql ? and then try docker exec (from inside) command ?

hajrovica left a reply on Cannot Connect To Database With Docker And Pdo_mysql In Laravel

yes can you check mysql users or even better create new user with full privileges and try that one ? maybe mysql users got messed - bcs there is no logic that with root you have full access outside of container but not inside,

and also in docker case i think this (using sequel pro to connect) does not count as outside connection

hajrovica left a reply on Error When Executing Factory

@varun-2301 yes i see you have updated code:

    return [
    'user_id' => NULL,
        'social_id'=>'' ,
        'age    '=>'',
        'gender'=>'',
        'fb_hash'=>'',
    ];

by your cod age does have spaces in name - you should have fix that, also i do not see a point of 'user_id' => NULL, if i run seeder with your settings i am getting error here

try the seed with 'user_id' => '', it should run fine

hajrovica left a reply on Cannot Connect To Database With Docker And Pdo_mysql In Laravel

ok ... then there should not be an issue when connecting with app though if i understood correctly you are getting error: SQLSTATE[HY000] [2002] Connection refused

cross reference your login data from sequelpro and .env file ?

hajrovica left a reply on Cannot Connect To Database With Docker And Pdo_mysql In Laravel

Module 'pdo_mysql' already loaded in Unknown on line 0 - that error comes for docker container just informing you that pdo is already loaded before uncomented pdo in php.ini though that should not hinder your ability to connect

Can you use some GUI client to connect to Mysql (i.e. HeidiSQL on Win) fire it up and try to connect to loclhost:3306 or127.0.0.1:3306 and see if you are successful ?

hajrovica left a reply on Error When Executing Factory

Hi, paste full error you are getting when running seeder,

but looking just factories you have posted i can see couple of possible issues:

  • you are calling user factory with 'user_type' => '1' - though you do not have that field in factory
  • consumer factory field 'age '=>'', you have spaces in field name
  • $user->consumerProfile() ... i suppose this is hasMany relationship - but in ConsumerFactory factory you do not have user_id ?

Though only guesses - put your migrations as factories and full error if you expect to get help ....

19 Apr
5 months ago

hajrovica left a reply on Sum Price In One Row And GrandTotal

hi @mmmuhd okay reduce is a method which goes over each array entry updating a reference to a key value, i cant say sure without looking at your code - but looking at my example

this.rows.reduce(function(total, item){

              return total + item.quantity; 
            },0);

this.rows could be issue, it could be undefined, or maybe that row is other type or similar. Can you log object on which you are calling reduce ?

12 Dec
9 months ago

hajrovica left a reply on Generating PDFs From Laravel Views

@hondaman900 Hi as i recall nothing specific was needed to install php-pdftk Pulled it with composer

used it in standard way: use mikehaertl\pdftk\Pdf;

can you share your code? also do composer selfupdate Check is your name space ok - i am not sure should it say Class 'Vendor\mikehaertl\pdftk\Pdf' not found or should it be Class 'mikehaertl\pdftk\Pdf' not found?

04 Mar
1 year ago

hajrovica left a reply on Recommendation On Reporting Framework For Laravel?

@seongbae - do you have any updates for this question? I am currently in similar need and KoolReport, Reportico and Jasper turned out after search. I am interested what did you eventually used and how it turned out ?

05 Feb
1 year ago
28 Jan
1 year ago

hajrovica left a reply on Mkdir On Laravel Production - Permission Denied

yep as @jryd mentioned, bascially this is not laravel issue but server issue. Contact you server admin to give your web server user proper permissions on specific folder where do you want to create files.

if you do have access to terminal you could do something like sudo chmod -R 755 path/to/folder but again that could leave ownership issues

02 Dec
1 year ago

hajrovica left a reply on How To Organize The Project Development Phase

ehh

https://github.com

https://bitbucket.org

i personally am fan of bitbucket far more then github.

13 Sep
2 years ago

hajrovica left a reply on Homestead On Windows

you create laravel project in your mapped folder, not in homestead folder. You can also do it in homestead machine after ssh in /home/vagrant/Code but that would be a long way

so in mattsplat example of yaml file

folders:
- map: c:/Repos/laravel
  to: /home/vagrant/Code

you would create new project in c:/Repos/laravel folder

12 Sep
2 years ago

hajrovica left a reply on How Can Print Index Value In V-text Or V-for?

ah sorry i did not understood question - Jeffry has a lesson about axios and data consumption - https://laracasts.com/series/learn-vue-2-step-by-step/episodes/18

Just short test Vue part

var app = new Vue({
el: '#app',
  data: {
    message: 'Hello Vue!', 
    info: [],



  },
  // methods: {
      
  // },
  mounted(){
    axios.get('/skills').then(response => this.info = response.data);
  },

  
    
})

basically declare property in this case "info" and in mounted function assign data from axios response to info variable you can even assign whole respone to it if you like

hajrovica left a reply on How Can Print Index Value In V-text Or V-for?

If you are using laravel then you use syntax

@{{ index }}

if not in laravel - not in blade it should be

{{ index }}

Vue Template syntax

hajrovica left a reply on How Can Print Index Value In V-text Or V-for?

Try this in your blade

 @{{index}}
08 Sep
2 years ago

hajrovica left a reply on Sum Price In One Row And GrandTotal

@Gabonator ok i am not sure what is not working though you are going with component i have recreated your OrderRows as i best i could as non component vue - by the way your link does not work

Html

    <h1>Vue</h1>

    <hr>

@{{ message }}
<div id="app">
    <div class="panel panel-default">
        <div class="panel-heading"><strong>Riadky</strong></div>
        <table class="table">
            <thead>
            <tr>
                <td>Por.</td>
                <td>položka</td>
                <td>Počet</td>
                <td>Cena/ks</td>
                <td>Spolu</td>
                <td></td>
            </tr>
            </thead>
            <tbody  style="background: rgba(220, 75, 78, 0.23)">
            <tr v-for="(index, row) in rows">
                <td>@{{ index +1 }}</td>
                <td><input placeholder="Položka" type="text" required name="itemName[]" value="@{{row.name}}" >  </td>
                <td><input placeholder="počet" type="number" required name="quantity[]" value="@{{row.quantity}}"  > </td>
                <td><input placeholder="cena" type="number" step="0.01" required name="price[]" value="@{{row.price}}" > </td>
                <td>Celkom: @{{ row.quantity * row.price }},- Euro </td>
                <td><button  class="btn btn-default btn-xs pull-right" @click="removeItem(index)">X</button></td>
            </tr>

            <tr>
                    <td>#</td>
                    <td class="">Items </td>
                    <td class="">quantity: @{{totalQuantity}}</td>
                    <td class=""></td>
                    <td class="">summ: @{{totalSumm}}</td>
                    <td class=""></td>

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

            <table class="table" style="margin-bottom: 55px">
                <thead>
                <tr>
                    <td><button @click="addRow" class="btn btn-primary btn-sm pull-left">Row</button></td>
                    <td class="pull-right">Spolu: </td>
                    <td>
                        <div class=" btn-group pull-right">

                            <button type="submit" name="order_send" value="0" class="btn btn-primary btn-sm">Uložiť</button>
                            <button type="submit" name="order_send" value="1"  class="btn btn-info btn-sm">Uložiť a odoslať</button>
                            <!--<a href="{{ url()->previous() }}" class="btn btn-default">Zrušiť</a>-->
                        </div>
                    </td>
                </tr>
                </thead>
            </table>
</div>

Vue Part

<script>
 var app = new Vue({
 el: '#app',
  data: {
  message: 'Hello Vue!',
  divs: [{number: '1'}, {number:'2'}],
   rows:[
        { name: "item1", quantity: 2, price: 100},
        { name: "item2", quantity: 1, price: 200},
        { name: "item3", quantity: 4, price: 100},
     ]
    },
    methods: {
        addRow: function() {
            var elem = document.createElement('tr');
            this.rows.push(elem);
        },
        removeItem: function(index) {
      this.rows.splice(index, 1);
      //                $(this.$el).fadeOut(300);
        }
    },
    computed:{
        totalQuantity: function(){
            console.log(this.rows);
            return this.rows.reduce(function(total, item){

              return total + item.quantity; 
            },0);
          }, 
          totalSumm: function(){

              return this.rows.reduce(function(total, item){

                return total + (item.quantity * item.price); 
              },0);
            }, 
    }
})

screenshot of example

example

https://ibb.co/fw0W8a

(not sure if i can embed image here)

07 Sep
2 years ago

hajrovica left a reply on Sum Price In One Row And GrandTotal

hi here is very simplified example how to do it

Html

<div class="divs" v-for="(index, item) in rows">
     <ul> no. @{{ item.index }} - @{{ item.number }}   </ul>

</div>
      Total: @{{total}}

Vue part

<script>
var app = new Vue({
  el: '#app',
  data: {
  
rows:[
        {index: '1', number: 4},
        {index: '2', number: 2},
        {index: '3', number: 1},
     ]
  },

  computed: {
  total: function(){
    console.log(this.rows);
    return this.rows.reduce(function(total, item){

      return total + item.number; 
    },0);
  }
}

})
</script>

Output

   no. 1 - 4
   no. 2 - 2
   no. 3 - 1
Total: 7
06 Sep
2 years ago

hajrovica left a reply on Export Pdf From Laravel

look at https://murze.be/2017/07/easily-covert-webpages-to-images-using-php/ it is about Browsershot v2 (Convert a webpage to an image or pdf using headless Chrome) from Spatie - definitely worth a look

hajrovica left a reply on Getting Data From Chain

ok you need to answer following question does your schedule has one or many serviceschedule entries?

and do dump of serviceshedule object just to see whit what you are working

Update - in this case it can be that you have null object and previous case it could have that you got empty collection

hajrovica left a reply on Getting Data From Chain

ah yes did not catch that - @tykus has a point here, you need to iterate

hajrovica left a reply on Getting Data From Chain

look at error Property [date] does not exist on this collection instance

and you are calling {{ $schedule->serviceschedule->date }} right

Do you have date property on serviceschedule model?

05 Sep
2 years ago

hajrovica left a reply on Generating PDFs From Laravel Views

Hi,

https://github.com/mikehaertl/php-pdftk - i have used this one and it was better option for me than laravel-snappy

and look here https://murze.be/2017/07/easily-covert-webpages-to-images-using-php/ it is about Browsershot v2 (Convert a webpage to an image or pdf using headless Chrome) from Spatie - definitely worth a look

hajrovica left a reply on How To Create More <div> Use Button

Here is my adaptation of one of older vue related posts

Html:

    <h1>Vue</h1>

    <hr>

    <div id="app">
      @{{ message }}
       <div class="list-group divs">
        
        <div class="list-group-item seat" v-for="item in divs">
          
          <div class="row">
            <div class="col-xs-6">
              <p>Seat [email protected]{{ item.number }}</p>
            </div>
            <div class="col-xs-6 text-right">
              <div class="form-inline">
                <input type="text" class="form-control input-sm" v-model="item.number">
                <button @click="cloneItem(item)" class="btn btn-sm btn-defadivt">Clone</button>
                <button @click="removeItem(item)" class="btn btn-sm btn-danger">Remove</button>
              </div>
            </div>
          </div>

        </div>


      </div>
      </div>
             <pre>@{{$data | json}}</pre>

JS

<script>
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!',
divs: [{number: '1'}]
 },

methods: {

    cloneItem: function(div) {      
    this.divs.push({ number: div.number });
  },
  
  removeItem: function(div) {
    this.divs.$remove(div);
  }

}

})
</script>

hajrovica left a reply on ErrorException Unlink(C:\Users\Hp\onlineShoppingCart\storage\app\public/images/13): Permission Denied

Seems that you actually are not deleting image in that command look at the error - public/images/13 after images is product_id which is 13 right? Where is image name after it? Seems that $image->name is empty

referencing this structure

 $image = new Images(['image' => $image->name, 'image_url' => asset('storage/images/'. $product->id ."/" . $image->name)]);

hajrovica left a reply on Phpunit Error 'No Test Executed!'

try to run vendor\bin\phpunit.bat

hajrovica left a reply on Best Practice To Pass A Single-value Variable To A View

@tykus has give you a great direction - normalize your schema.

Basically if you don't wanna to have townname in your result you should have then town_id but fact is still there you will have some town related data for each month if it is defined in table.

And it is easier to get data as you have been and groupby key and display town data once at the top and not show it again then to write costum queries omitting or hiding data for set of records ...

Also if you are such perfectionist you can try and use forget() method to omit specific data from your results but again it is time consuming and harder ...

hajrovica left a reply on Wrong Data Being Returned After Foreach

Not sure this is ok

Site model -> belongsToMany(Service::class)

Service Model has many shcedules - ok

Third option you have labeled My Site ? If this is Service Model then ok i can see setup where Site has many Service and Service has many sites. is this Service Model ?

But all time you are referring to the fact that you want to see services for one particular site and schedules for specific service or all services regarding to the one specific site am i right?

And i am not sure what this means:

Does that make sense, but the other issue is that it is bringing all the sites that the user is associated with and not just the site they are viewing?

what is bringing all the sites ?

hajrovica left a reply on Renaming The Default App\User Model Leads To Not Being Able To Login Anymore

I hear you, you are not alone, oh how many times i have searched error for hours just to see that whole time it was in my plain sight :)

hajrovica left a reply on Renaming The Default App\User Model Leads To Not Being Able To Login Anymore

You need to pass a hashed password for user if i am not mistaking Laravel wont do it for you automatically.

Check RegisterController.php in your project

/**
 * Create a new user instance after a valid registration.
 *
 * @param  array  $data
 * @return User
 */
protected function create(array $data)
{
    return User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        'password' => bcrypt($data['password']),
    ]);
}

as you see password is bcrypted, so when creating factory try this

factory(App\Admin::class)->create(['password' => bcrypt('password')])

hajrovica left a reply on Wrong Data Being Returned After Foreach

Basically you are getting error that schedule_id column does not exist in sites table which is prerequisite for this relation. I am not sure how are you going about DB setup but in my view schedule in this case would not have many Sites and schedule id should not be in sites table ...

I would go about this following this logic:

  • Site has one or more services (Site has many Service)
  • Service has one or more schedules (Service hasMany Schedule or if you want inverse relation Schedule belongs to Service )
  • And ultimately Site hasMany Schedule Through Service relation

so double check your db setup

Also in your example {{ $schedule->service_schedules->date }} date of service schedule should be in sites table - i dont think so ...

So again double check db setup

04 Sep
2 years ago

hajrovica left a reply on How To Read Barcode Data From Barcode Scanner

i think @ModestasV meant to use html auto focus attribute which will cause one filed with that attribute to be focused after page load and ready for data entry

check here https://www.w3schools.com/tags/att_input_autofocus.asp

So basically you can have page with one filed with auto focus enabled as data entry point. Most of barcode scanners are sending enter key at the end which will trigger your form processing and sent your data automaticly

hajrovica left a reply on Wrong Data Being Returned After Foreach

this part of code

$sites = Site::findOrFail($id);

foreach ($sites->services as $service)
  {
....

means that you have site which has some services relation so services is collection.

and this part

merge($service->schedules)

means, at least for me that service has some or none schedules recorded. So if you wanna to get all schedules for site you could go something like this

//create schedules collection
$schedules = collect();
foreach ($sites->services as $service)
{
$schedules->push($service->schedules)

 }

i am not sure about structure of data but i would try to push all schedules from each service to schedules collection and try to flatten it at the end - if possible against doing another foreach like this

//create schedules collection
$schedules = collect();
foreach ($sites->services as $service)
{
    foreach ($service->schedules as $schedule){
        $schedules->push($schedule)
    }

}

this would give us all schedules of different services done at the site if i am not mistaken

hajrovica left a reply on Wrong Data Being Returned After Foreach

You have some site by id, and that site has services and each service has schedules. And you want to list all schedules for that site right?

if so i am not sure what you are trying to achieve with this piec of code

$schedules = $schedules->where('first_service_date', '>', $from)->where('first_service_date', '<', $to)->merge($service->schedules);

you are doing where on empty collection and merging schedules into it?

From where is $from and $to coming?

Would not be easier to do something like this:

  • get site by id
  • loop through each recorded service for that side
  • add schedules for each service (not merge) to schedules collection
  • then if needed do some queries related to dates and so on

?

hajrovica left a reply on Looping Through A Table

yep that was my next issue so in your example you named relation between category and services as prices?

Anyway i am glad it worked :)

hajrovica left a reply on Looping Through A Table

So you get prices for all services:

$services_options = Price::all();

but how do you distinguish in which category this services belongs to? I don't see that information here?

hajrovica left a reply on Looping Through A Table

Ok issue here is a that your collection is structurally different from my example - you need to adapt code i posted to your structure. Principle is the same. You have some services which are in some categories you need to get those categories and in foreach take each category by name or id and loop through services.

please do dump of $services_options->toArray() and post it

hajrovica left a reply on Looping Through A Table

dump $service_category seems you have data which is not integer or string in there?

03 Sep
2 years ago

hajrovica left a reply on Missing Form Data In Chrome (61)

hmmm i just checked Form Data is under Headers at the end. Chrome beta channel - Version 61.0.3163.71 (Official Build) beta (64-bit) - no extensions

Did you tried to disable extensions and see if it is there?

hajrovica left a reply on How Do We Do Crud Operation On Multiligual Project?

I am not sure what you are asking and how it is not clear? Second tutorial on package page is this it gives even more thorough tutorial but also does not solves interface issue.

Reason for this: it is something you need to figure out how will be done - it depends on how much languages you wanna to have on site, will one person enter all translations or only one and so on.

Easiest way for interface would be lets say if you have blog, with title and text, to display another title and text boxes with languages selector on edit/new page for that blog. And to update/create default text as its translation.

hajrovica left a reply on Change Of Enviroment (removing A Project From Windows To Ubuntu )

What version of Laravel? Did you checked issues on GitHub page regarding this error.

Also you have a bit more options when you want to work with pdf and laravel. Personally i have used php-pdftk package - it needs a different approach but for me it was better option.

Also check this one Browsershot article, i haven't tried it yet but i intend to.

hajrovica left a reply on Looping Through A Table

ok can you post code which is giving you this error and $services_options structure?

hajrovica left a reply on Roles In Logging In

just search "role" here on site