Eco012390

Eco012390

Member Since 3 Years Ago

Experience Points 31,380
Experience Level 7

3,620 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 155
Lessons
Completed
Best Reply Awards 0
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.

18 Dec
6 months ago
10 Oct
8 months ago

Eco012390 started a new conversation How To Host Laravel In A Sub-folder

I have a project in laravel that requires to be served at a sub folder. https://mainsiteinwordpress.com/laravelsite

Both site uses apache2 web server and they are in seperate server.

Is it possible to make this work?

I tried using URL::forceRootUrl(‘mainsiteinwordpress.com/laravelsite’)

It worked locally but I got an error in production php_remote_network error something.

06 Jun
1 year ago

Eco012390 started a new conversation Does Importing Or Using More Models On A Controller Slows Down The Request On The Endpoint?

Does importing or using more models on controller even though it is not being used slows down the request on the endpoint?

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\User;
use App\Model1;
use App\Model2;
use App\Model3;
use App\Model4;
use App\Model5;
use App\Model6;
use App\Model7;
use App\Model8;
use App\Model9;
use App\Model10;

class UserController extends Controller
{
    public function index($url)
    {
        return User::all();
    }
}

VS.

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\User;

class UserController extends Controller
{
    public function index($url)
    {
        return User::all();
    }
}

I plan on doing this pattern but I'm afraid it would slow down my endpoint

// Controller Class
<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Http\Request;
use App\User;
use App\Model1;
use App\Model2;

/**
 * Class Controller.
 */
class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    public function __construct()
    {
        $this->User = User;
        $this->User = Model1;
        $this->User = Model2;
    }
}

// UserController
<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;

class UserController extends Controller
{
    public function index($url)
    {
        return $this->User::all();
    }
}

Any thoughts?

25 Apr
1 year ago

Eco012390 started a new conversation Does Downloading A File From Server Consumes VPS Bandwidth?

Hi I just want to know does this code consumes bandwidth at the server? also, does it stress the server?

return response()->download($largefile);
04 Apr
1 year ago

Eco012390 started a new conversation How To Create Custom Directory Shortcut? Using Laravel Mix

I have a project and want to create a custom shortcut.

For example, I have a chat component on this path resources/assets/js/components

and I want to import chat component from components directory from Vue router directory

resources/assets/js/router/index.js

// Instead of this
import Chat from '../components/Chat'

// I want it to be like this
import Chat from '@components/Chat'

In summary, I want

'@components' to be mapped to 'resources/assets/js/components'

15 Mar
1 year ago

Eco012390 started a new conversation Why Does Laravel And Lumen Has Different Testing Methods?

Why does laravel and lumen has different testing methods?

12 Mar
1 year ago

Eco012390 started a new conversation Dynamically Synchronous Request Axios

How do I make an axios synchronous request dynamically?

var array = [0,1,2];
axios.get('api/' + array[0]).then(response => {
    axios.get('api/' + array[1]).then(response => {
         axios.get('api/' + array[2]).then(response => {
            alert('done');
         });
    });
});
09 Mar
1 year ago

Eco012390 left a reply on ?string Syntax Of What PHP?

@Snapey sorry but it's not possible in my current circumstances right now.

Any other solutions?

Eco012390 started a new conversation ?string Syntax Of What PHP?

__construct(?string $Locale

Hi guys.

I did a composer update on my project and now I'm having trouble with symphony errors with this syntax ?string at vendor/symfony/translation/Translator.php

how do I revert back to the old laravel that has no dependency the newer symfony?

01 Mar
1 year ago

Eco012390 started a new conversation Supervisor And Laravel Queue Work

How many numprocs can I run on a 1gb memory VPS?

20 Feb
1 year ago

Eco012390 left a reply on How To Query Json Column Array.

Made it work by doing this

$arr = ['a', 'b'];
$arr = (string) json_encode($arr);
$arr = "'" . $arr . "'";

$query->whereRaw('JSON_CONTAINS(map_data->"$.band",'. $arr.')');

What's the better to write this?

19 Feb
1 year ago

Eco012390 started a new conversation How To Query Json Column Array.

I tried doing this

// Migration
$table->json('map_data')->nullable();

// Map data is
map_data = {
    'bands' => ['1', '2'],
}

// Query
$query->whereIn('map_data->bands', ['1']);


I'm getting this error

QLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'bands,

18 Feb
1 year ago

Eco012390 left a reply on Migration And Seeding Is Slower In Local Machine Than Homestead

I noticed that this happens only when my localhost uses a standard drive.

The seeding is even faster than homestead on a standard drive when using an SSD at localhost.

So I'm assuming that VirtualBox somehow speeds up the drive of the homestead box.

19 Jan
1 year ago

Eco012390 started a new conversation Chat Support Ticket Application Using Laravel Echo Question

Hi Guys,

I'm trying to make a chat support application using Laravel with Echo, now my problem is that in order to use Laravel Echo to the fullest the connection must be on private and not on the channel only because features like the whisper are not available in Echo.channel.

I want the application to have a support for embed chat, but I am thinking that they should not be authenticated. But since they're not authenticated then how do I use the Echo.whisper or the channels.php authorization route?

The main question is should I authenticate the user on the embedded chat when they initiate a ticket request? I also want the embed chat to work other sites by just a script tag, but the problem with that is that I think that they won't be able to authenticate using the embedded chat script.

Should I use a Token based authentication? If I will use a token based authentication then what's the most appropriate to use JWT Auth or Laravel Passport?

Thanks!

10 Jan
1 year ago

Eco012390 started a new conversation How Do I Orderby Relationship Value Using The Code In This Lesson Https://laracasts.com/series/eloquent-techniques/episodes/4

Hi Guys can't seem to figure out how to orderby relationship value.

public function sortby($sortby = null) {
return $this->builder->whereHas('attributes', function ($q) use ($sortby) {

                   $q->where('name', 'For Rent')->orderBy('value',  $sortby);
           })
}

21 Dec
1 year ago

Eco012390 started a new conversation Laravel Echo Private Channel For Guest User How?

How do I setup a Laravel private channel for guests?

Laravel Echo

 Echo.private('ticket.1')

channels.php

Broadcast::channel('ticket.{id}', function ($user, $id) {
    // this only works if user is logged in.
});
21 Nov
1 year ago

Eco012390 started a new conversation Axios Is Not Defined But I Defined It Globally On Vue Webpack

Hi guys

I have this line of code at the top of my app.js

window._ = require('lodash')
window.axios = require('axios')

My problem is I'm getting an error of axios is not defined or ._ is not defined when using it in Vue component

Does not work

export default {
    mounted () {
        axios.get('test')
    }
}

Works with window.

export default {
    mounted () {
        window.axios.get('test')
    }
}

It's weird because this works in laravel but in vue webpack it does not work.

07 Nov
1 year ago

Eco012390 started a new conversation How To Pass Curl Resource In Jobs Queue?

Hi guys is it possible to pass a curl resource in laravel queue? I'm creating a scraper for a client and it needs to login then download a webpage but I need the curl resource to stay in the in the queue but when I pass it to the Job class curl resource becomes 0

19 Oct
1 year ago

Eco012390 left a reply on Help How To Do Apache2 Subdirectory Setup For Laravel

Looks just like what I needed. Thanks will try this tomorrow.

Eco012390 left a reply on Help How To Do Apache2 Subdirectory Setup For Laravel

Whats the difference of aliasMatch on alias.

I have tried alias but there are some Problems with it

17 Oct
1 year ago

Eco012390 started a new conversation Help How To Do Apache2 Subdirectory Setup For Laravel

mydomain.com -> normal php site. mydomain.com/beta -> laravel site

how do I do this in apache?

this is my current apache config

<VirtualHost 127.0.0.1:80>
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot /home/mydomain/public_html/mydomain/public
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory "/home/mydomain/public_html/mydomain/public">
Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
AddType application/x-httpd-php .php
AddHandler fcgid-script .php
AddHandler fcgid-script .php5
AddHandler fcgid-script .php5.5
AddHandler fcgid-script .php5.6
AddHandler fcgid-script .php7.0
FCGIWrapper /home/mydomain/fcgi-bin/php7.0.fcgi .php
FCGIWrapper /home/mydomain/fcgi-bin/php5.fcgi .php5
FCGIWrapper /home/mydomain/fcgi-bin/php5.5.fcgi .php5.5
FCGIWrapper /home/mydomain/fcgi-bin/php5.6.fcgi .php5.6
FCGIWrapper /home/mydomain/fcgi-bin/php7.0.fcgi .php7.0
</Directory>
<Directory /home/mydomain/cgi-bin>
allow from all
AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.mydomain.com
RewriteRule ^(.*) https://mydomain.com:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.mydomain.com
RewriteRule ^(.*) https://mydomain.com:10000/ [R]
RemoveHandler .php
RemoveHandler .php5
RemoveHandler .php5.5
RemoveHandler .php5.6
RemoveHandler .php7.0
php_admin_value engine Off
FcgidMaxRequestLen 1073741824
Alias /beta "/home/mydomain/public_html/mydomain/public/beta"
</VirtualHost>
02 Oct
1 year ago

Eco012390 started a new conversation PHP Library To Increase Image Size And Quality

Anyone knows a PHP/Laravel Library that increases Image Size and Quality similar to this

https://www.photoenlarger.com/

Thanks in advance

27 Sep
1 year ago

Eco012390 left a reply on Laravel Branching

Im wondering why does master branch is ahead of develop branch.

Eco012390 started a new conversation Laravel Branching

Difference between master branch and develop branch in laravel framework github.

25 Sep
1 year ago

Eco012390 left a reply on Array To String Conversion

My price variable is in array that's why

Eco012390 started a new conversation Array To String Conversion

"Array to string conversion (SQL: insert into bookings (comment, booking_date, arrival, departure, price, adults, child, status_id, property_id, updated_at, created_at) values (asdxa, 2017-09-25 00:00:00, 2017-09-26 00:00:00, 2017-09-28 00:00:00, 580, 1, 0, 11, 1954, 2017-09-25 15:31:54, 2017-09-25 15:31:54))"

24 Sep
1 year ago

Eco012390 started a new conversation How To Delay Script Execution In Vue

I'm trying to mimic this but mine was too fast and there is no focus on map https://hpneo.github.io/gmaps/examples/routes_advanced.html

Here is my jsfiddle https://jsfiddle.net/50wL7mdz/64080/

Thanks in advance

23 Sep
1 year ago

Eco012390 left a reply on How Do I Execute A Vue Click Event On Appended String?

I can't do that because I'm implementing it together with google maps info window.

https://jsfiddle.net/50wL7mdz/63957/

Eco012390 started a new conversation How Do I Execute A Vue Click Event On Appended String?

How do I execute a vue click event on appended string?

https://jsfiddle.net/50wL7mdz/63946/

21 Sep
1 year ago

Eco012390 started a new conversation A Website That Shares Code For Custom Validation Rules

A website that shares code for custom validation rules is there a website like this?

Eco012390 left a reply on Install Laravel Project In Linux Mint

Virtualhost is used to have a pretty url imitating what it should be in production.

I'm also on Linux mint and I use this https://github.com/cpriego/valet-linux for my development environtment. It should be a breeze.

Eco012390 left a reply on Load Latest Posts To Footer Area

You can either make view composer and do the query in there or directly query in the footer.blade like these

<footer>
{{  \App\Posts::orderBy('created_at', 'dsc)->take(3)->get() }}
</footer>
19 Sep
1 year ago

Eco012390 started a new conversation Route::resource Without Only Or Except Affects Performance?

If I use Route::resource and I only need the index and I didn't use the only method and I got lot's of these.

Will it affect performance?

07 Sep
1 year ago

Eco012390 started a new conversation How Does Booking Channel Manager Work?

Does any of you have any experience using a booking channel manager?

I wonder how do you integrate it with a Laravel app.

  1. Do I have to pull every booking list from the channel manager then update my own database or does the Channel Manager automatically sends it through my endpoint and I just need to set up that endpoint?
06 Sep
1 year ago

Eco012390 left a reply on Mutator Is Not Working On Id Public Function SetIdAttribute($value) {}

It turns out that my problem is on the database side not the eloquent mutator. mysql automatically converts 000001 to 1

Eco012390 started a new conversation Mutator Is Not Working On Id Public Function SetIdAttribute($value) {}

public function setIdAttribute($value) { $this->attributes['id'] = sprintf("%'.06d\n", $value); }

Eco012390 started a new conversation How Do I Generate An ID With Minimum Length Of 6?

e.g

1 = 000001

10 = 000010

100 = 000100

1000 = 001000

is it advisable to do this when storing to db as booking id?

04 Sep
1 year ago

Eco012390 started a new conversation Does It Slow Down My App If I Have Too Many Routes?

Does it slow down my app if I have too many routes?

26 Aug
1 year ago

Eco012390 left a reply on How Do I Avoid A Overbooking When 2 Customer Pays At The Same Time?

Isnt this exploitable by your competitors by reserving many seats and not completing the transaction and repeating it again?

25 Aug
1 year ago

Eco012390 started a new conversation How Do I Avoid A Booking Duplication When 2 Customer Pays At The Same Time?

Is it good to queue a checkout payment process?

How do I avoid a booking duplication when 2 customer pays at the same time?

24 Aug
1 year ago

Eco012390 started a new conversation Custom Validation Rule Does Not Work On Every 2nd Attempt

Validator::extend('available', function ($attribute, $value, $parameters, $validator) {
            $property = Property::find(request('id'));

            if ( ! $property) {
                return true;
            }

            foreach ($property->blockedDates()->get() as $booking) {
                if (
                    Carbon::parse(request()->dates['from']) <= Carbon::parse($booking->departure) &&
                    Carbon::parse(request()->dates['to']) >=  Carbon::parse($booking->arrival)
                ) {
                    return false;
                }
                return true;
            }

            return true;
        });

What I'm doing is I'm checking if your requested dates intersected with the property blocked dates.

My problem is that the Custom Validation Rule does not work on every 2nd attempt.

but when I do this. It works on every request

Validator::extend('available', function ($attribute, $value, $parameters, $validator) {
            return false;
        });

23 Aug
1 year ago

Eco012390 left a reply on How Do I Make A Class Similar To Laravel Jobs Class?

@danmatthews just wanna make my controller super slim.

// This is what I currently do.

$data = new TestClass(1, 2);
$data->handle();

// I want it to be 
$data = new TestClass(1, 2);

Eco012390 started a new conversation How Do I Make A Class Similar To Laravel Jobs Class?


class TestClass {
    protected $var1;
    
    protected $var2;
    
    public function __construct($var1, $var2)
    {
        $this->var1 = $var1;
        $this->var2 = $var2;    
    }

    public function handle()
    {
        return $this->var1 + $this->var2;
    }
}

class HomeController extends Controller {
    public function index()
    {
        $data = new TestClass(1, 2);
        
        dd($data);
        
        // output: 3
    }
}

17 Aug
1 year ago

Eco012390 started a new conversation How Does Laravel-mix Knows That Import Moment From 'moment' Comes From Node_modules?

How does laravel-mix knows that import moment from 'moment' comes from node_modules?

I was planning to create my own 'resources/assets/packages' directory similar to 'node_modules' directory but for the packages I edited slightly so that it won't be overwritten when I npm update or when I deleted my node_modules folder.

import package from '@/packagename'

I want the @ symbol to be directed to my resources/assets/packages path.

How do I do this?

16 Aug
1 year ago

Eco012390 left a reply on How Do I Force A Unique Rule To Ignore A Given String?

found out the solution

use Illuminate\Validation\Rule;

$this->validate(
            $request,
            [
                'name' => [
                    'required',
                    Rule::unique('properties')->ignore($property->name, 'name'),
                ],
                'type' => 'required',
            ]
        );

Eco012390 started a new conversation How Do I Force A Unique Rule To Ignore A Given String?

$this->validate(
            $request,
            [
                'name' => 'required|unique:properties,name,'.$property->name,
                'type' => 'required',
            ]
        );

Eco012390 started a new conversation Hi Guys How Do I Automatically Create My Model Relationship Values?

        $property = new Property;
        $property->name = $request->propertyName;
        $property->owner_id = $propertyOwner->id;
        $property->type = $request->type;
        $property->save();

        $propertyAddress = new PropertyAddress;
        $propertyAddress->property_id = $property->id;
        $propertyAddress->save();

        $PropertyBlockPeriod = new PropertyBlockPeriod;
        $PropertyBlockPeriod->property_id = $property->id;
        $PropertyBlockPeriod->save();

How do I make this shorter?

14 Aug
1 year ago

Eco012390 started a new conversation Does Lot's Of Small Queries Slow Downs The Search?

The scenario is I have a Property model that I need to search.

class Property extends Model {
    
    protected $appends = ['pricePerWeek'];
    
    public function getPricePerWeekAttribute() 
    {
        $this->prices
               ->where('date', '>=', Carbon::now()->toDateString())
                   ->where('price', '>', 0)
                   ->sortBy('price');
    }
}

https://laravel.com/docs/5.4/eloquent-serialization#appending-values-to-json

This added a single query on my search for every property.

Is this a good approach?

Eco012390 started a new conversation HI Guys I Need Help Solving These Problem Of Mine Regarding Dates

I wonder if any of you encounter these problem.


// I have this array of date range for saturday to saturday only booking
$satsatDates = array:2 [▼
  0 => array:3 [▼
    "from" => "2017-07-01"
    "to" => "2017-09-02"
    "satsat" => true
  ]
  1 => array:3 [▼
    "from" => "2018-06-30"
    "to" => "2018-09-01"
    "satsat" => true
  ] 
]
// And I want to merge these into today to a year range and split them up
 $start = Carbon::now();
 $end = Carbon::now()->addYear();

// How do I split them so I can have this results
$dates = [
            [
                'from' => '2017-07-01',
                'to' => '2017-09-02',
                'satsat' => true
            ],
            [
                'from' => '2017-09-03'
                'to' => '2018-06-29',
                'satsat' => false,
            ],
            [
                "from" => "2018-06-30"
                "to" => "2018-09-01",
                'satsat' => true
            ]
        ];

Please suggest how do I solve this or where should I ask to solve this or what should I do to solve this.

Thanks!