MartinZeltin

MartinZeltin

Member Since 1 Year Ago

Experience Points
19,840
Total
Experience

160 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
132
Lessons
Completed
Best Reply Awards
0
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 4
19,840 XP
19 Sep
1 day ago

MartinZeltin left a reply on How To Update Model Using Scope?

I wasn't aware of soft deleting, I will have to look into it. I'm fairly new to Laravel, still learning. Thank you for pointing me in the right direction!

MartinZeltin left a reply on How To Update Model Using Scope?

Thank you, yes you are right. It looks like it is working!

MartinZeltin started a new conversation How To Update Model Using Scope?

I am trying to create a softDelete() method for my Model but I can't understand how to do this.

I would like to be able from my Controller to do this, and it would update is_deleted to 1:

User::where('id', 2)->softDelete();

Here is my Users table

+----+----------+------------+
| id | username | is_deleted |
+----+----------+------------+
| 1  | john     | 1          |
| 2  | jack     | 0          |
| 3  | joel     | 0          |
+----+----------+------------+

Here is my Model

class User extends Model
{
    public function scopeSoftDelete($query)
    {
        return $query->update(['is_deleted' => 1]);
    }
}

What am I doing wrong? Am I using scope in the wrong way?

05 Sep
2 weeks ago

MartinZeltin left a reply on Toggles

@sarahs74 Don't press the "Best answer" until you solve the issue, otherwise everyone will think that you already solved it.

04 Sep
2 weeks ago

MartinZeltin started a new conversation ErrorException: Trying To Get Property Talk_time Of Non-object

I have a collection that I am trying to filter but it is giving me an error. I can't understand why because I know that this property does exist on this collection as can be seen from the dump.

What is happening here?

  $collection = $collection->filter(function ($item, $key) use ($limit) {
      return $item->talk_time > $limit;
  });
  ErrorException: Trying to get property talk_time of non-object

dump

object(Illuminate\Support\Collection)#1008 (1) {
  ["items":protected]=>
  array(30) {
    [0]=>
    array(3) {
      ["user_id"]=>
      int(30)
      ["day"]=>
      string(10) "2019-09-02"
      ["talk_time"]=>
      int(1713)
    }
    [1]=>
    array(3) {
      ["user_id"]=>
      int(30)
      ["day"]=>
      string(10) "2019-09-03"
      ["talk_time"]=>
      int(2154)
    }
    [2]=>
    array(3) {
      ["user_id"]=>
      int(30)
      ["day"]=>
      string(10) "2019-09-04"
      ["talk_time"]=>
      int(1488)
    }
}

$collection->all() outputs the following...

Array
(
    [0] => Array
        (
            [user_id] => 30
            [day] => 2019-09-02
            [talk_time] => 1713
        )

    [1] => Array
        (
            [user_id] => 30
            [day] => 2019-09-03
            [talk_time] => 2154
        )

    [2] => Array
        (
            [user_id] => 30
            [day] => 2019-09-04
            [talk_time] => 1488
        )
)

MartinZeltin left a reply on How To Merge 2 Collections Together?

awesome, that worked!

MartinZeltin left a reply on How To Merge 2 Collections Together?

@geraintp yes, it looks like this is what I was looking for (merging on user_id).

$merged = $col_one->map(function ($item) use ($col_two) {
      return  array_merge($item, $col_two->firstWhere('user_id', $item['user_id']));
 });

I guess it would be nice if there was a collection method that allowed to merge on key like this...

   $merged = $collection_one->merge($collection_two)->on('user_id');

isn't that elegant?

MartinZeltin left a reply on How To Merge 2 Collections Together?

@resin try this, it isn't working....

        $array1[] = [
            'user_id' => 1,
            'username' => 'johnive3',
            'posts' => 569,
        ];

        $array1[] = [
            'user_id' => 2,
            'username' => 'elliot',
            'posts' => 9,
        ];

        $array2[] = [
            'user_id' => 1,
            'username' => 'johnive3',
            'comments' => 1569,
        ];

        $array2[] = [
            'user_id' => 2,
            'username' => 'elliot',
            'comments' => 19,
        ];

        $collection_one = collect($array1);
        $collection_two = collect($array2);

        $merged = $collection_one->merge($collection_two);

        dump($merged->all());

result

array:4 [
  0 => array:3 [
    "user_id" => 1
    "username" => "johnive3"
    "posts" => 569
  ]
  1 => array:3 [
    "user_id" => 2
    "username" => "elliot"
    "posts" => 9
  ]
  2 => array:3 [
    "user_id" => 1
    "username" => "johnive3"
    "comments" => 1569
  ]
  3 => array:3 [
    "user_id" => 2
    "username" => "elliot"
    "comments" => 19
  ]
]

MartinZeltin left a reply on How To Merge 2 Collections Together?

I couldn't find any collection method that could do this

MartinZeltin started a new conversation How To Merge 2 Collections Together?

I have 2 collections that I would like to merge but the merge() method doesn't seem to do what I expect.

Collection one

$collection_one = collect([
    'user_id' => 1,
    'username' => johnive3,
    'posts' => 569,
]);

  // 0 => array:3 [
  //   "user_id" => 1
  //   "username" => "johnive3"
  //   "posts" => 569
  // ],

  // 1 => array:3 [
  //   "user_id" => 105
  //   "username" => "larry_one"
  //   "posts" => 81
  // ],

  // 2 => array:3 [
  //   "user_id" => 7
  //   "username" => "sally25"
  //   "posts" => 1
  // ]

Collection two (added comments for each user)

$collection_two = collect([
    'user_id' => 1,
    'username' => johnive3,
    'comments' => 12,
]);

// 0 => array:3 [
//   "user_id" => 1
//   "username" => "johnive3"
//   "comments" => 12
// ],

// 1 => array:3 [
//   "user_id" => 105
//   "username" => "larry_one"
//   "comments" => 84
// ],

// 2 => array:3 [
//   "user_id" => 7
//   "username" => "sally25"
//   "comments" => 984
// ]

Expected result

[
    'user_id' => 1,
    'username' => johnive3,
    'posts' => 569
    'comments' => 12,
]

// 0 => array:3 [
//   "user_id" => 1
//   "username" => "johnive3"
//   "posts" => 569
//   "comments" => 12
// ],

// 1 => array:3 [
//   "user_id" => 105
//   "username" => "larry_one"
//   "posts" => 81
//   "comments" => 84
// ],

// 2 => array:3 [
//   "user_id" => 7
//   "username" => "sally25"
//   "posts" => 8
//   "comments" => 984
// ]
03 Sep
2 weeks ago

MartinZeltin left a reply on How To Transform A Collection Where Each Property Becomes A New Item?

This gave me an error:

message: "array_diff_key(): Argument #1 is not an array"

MartinZeltin started a new conversation How To Transform A Collection Where Each Property Becomes A New Item?

Hello, I have a collection where I have data for users (their posts, comments and reputation). I would like to transform this collection where each item becomes one of the three properties (posts, comments and reputation).

So the result would be like - for field: 'posts' and user_id: 46 we have 1542 posts. And for field: 'comments' the same user has 2. etc.

I tried to create multiple loops over the collection to get to this result but it is not working as I don't know how may loops I need. Is there a better and more clean way to do this?

Here is my original collection

"data": [
    {
        "user_id": 46,
        "username": "johnive",
        "posts": 1542,
        "comments": 2,
        "reputation": 48.5,
    },

    {
        "user_id": 30,
        "username": "zacky13",
        "posts": 54,
        "comments": 16,
        "reputation": 14.3,
    },

    {
        "user_id": 107,
        "username": "lil_elf4",
        "posts": 564,
        "comments": 60,
        "reputation": 67.5,
    },
],

Here is the result I would like to achieve

"data": [
    {
        "user_id": 46,
        "username": "johnive",
        "field": "posts",
        "value": 1542
    },

    {
        "user_id": 46,
        "username": "johnive",
        "field": "comments",
        "value": 2
    },

    {
        "user_id": 46,
        "username": "johnive",
        "field": "reputation",
        "value": 48.5
    },

    {
        "user_id": 30,
        "username": "zacky13",
        "field": "posts",
        "value": 54
    },

    {
        "user_id": 30,
        "username": "zacky13",
        "field": "comments",
        "value": 16
    },

    ...
],

I tried using multiple loops seems like a dirty way to do it and I don't know how many loops I would need.

foreach ($collection as $item)
{
  $new_item = new stdClass;

  $new_item->user_id = $item->user_id;
  $new_item->username = $item->username;
  $new_item->field = 'posts';
  $new_item->value = $item->posts;
}

foreach ($collection as $item)
{
  $new_item = new stdClass;

  $new_item->user_id = $item->user_id;
  $new_item->username = $item->username;
  $new_item->field = 'comments';
  $new_item->value = $item->comments;
}

foreach ($collection as $item)
{
  $new_item = new stdClass;

  $new_item->user_id = $item->user_id;
  $new_item->username = $item->username;
  $new_item->field = 'reputation';
  $new_item->value = $item->reputation;
}
19 Aug
1 month ago

MartinZeltin left a reply on Is It Possible To DRY This Code (only 2 Lines Change)

Thanks, that does seem cleaner than what I had before.

MartinZeltin started a new conversation Is It Possible To DRY This Code (only 2 Lines Change)

Hello, I am trying to get data with applied filters. And then with almost identical code to get sums and averages.

But 90% of it is repeated code (only the first and the last lines are different). Is there a way to avoid repeating myself like this? I know that this is probably not going to scale either.

/** NEEDS TO DRY **/
    $payments       = Payments::select('clients.id', 'employees.full_name', 'payments.employee_id', 'payments.id', 'payments.receive_date');
    $payments       = $payments->join('clients', 'clients.id', '=', 'payments.id');
    $payments       = $payments->join('employees', 'employees.id', '=', 'payments.employee_id');
    $payments       = $this->applyFilters($payments);
    $payments       = $payments->whereBetween('payments.receive_date', [$this->date_from, $this->date_to]);
    $payments       = $this->paginate($payments);


    $total_sums     = Payments::selectRaw("sum(price) as _sum_price, avg(price) as _avg_price, sum(remaining) as _sum_remaining");
    $total_sums     = $total_sums->join('clients', 'clients.id', '=', 'payments.id');
    $total_sums     = $total_sums->join('employees', 'employees.id', '=', 'payments.employee_id');
    $total_sums     = $this->applyFilters($total_sums);
    $total_sums     = $total_sums->whereBetween('payments.receive_date', [$this->date_from, $this->date_to]);
    $total_sums     = $total_sums->first();
/** NEEDS TO DRY **/
14 Aug
1 month ago

MartinZeltin left a reply on TokenMismatch - With Multiple Laravel Projects On One Server

The reason I specified the domain was because I have one Laravel project that is spread across multiple subcomains that should share the same authentification across all subdomains.

Laravel1 project routes:

forum.ultimategaming.com
blog.ultimategaming.com

Laravel2 project routes:

laravel2.ultimategaming.com

I only specified session domain for Laravel1 project.

MartinZeltin left a reply on TokenMismatch - With Multiple Laravel Projects On One Server

I changed the APP_NAME for each project but that didn't help.

I have an Apache server. The SESSION_DRIVER is set to file. Also these Laravel projects share the same domain with one.domain.com two.domain.com three.domain.com etc.

13 Aug
1 month ago

MartinZeltin started a new conversation TokenMismatch - With Multiple Laravel Projects On One Server

I noticed a strange behavior. I have multiple Laravel projects on one server. When I log into one project and then try to log into another project (different sub domains) I get a TokenMismatchException.

But when I have not logged in to any project and I try to log in then it works. What could be causing this? Any ideas?

in config/session.php I have this

'domain' => '.mydomain.com',
12 Aug
1 month ago

MartinZeltin left a reply on How To Make Any Route Except For '/login/'

Thank you, that worked!

MartinZeltin started a new conversation How To Make Any Route Except For '/login/'

I have a Route to any for a SPA. But I don't want to include '/login/' in the any rule. I can't figure out how to achieve this.. Any help would be much appreciated.

Here is my Route. Instead of "any", I would really like to say this - any route (except /login)

Because with the current route I end up in an infinite redirect loop.

Route::domain('forum.ultimategamerz.com')->group(function ()
{
    Route::get('{any?}',    '[email protected]')->where('any', '.*');
});
30 Jul
1 month ago

MartinZeltin left a reply on Call To A Member Function ToSql() On Array

True, but the bindings are separated from the query. I was thinking if it is possible to have bindings in the query.

like this

SELECT id, reply_text, sending_time
   FROM inbox_replies
   WHERE number IN ('123', '456', '789')

MartinZeltin left a reply on What Should I Learn, Vue Native Or React Native?

I would say if you already have experience with Vue and you like Vue then it would make sense to choose it. Build on our existing knowledge. Vue is also much simpler than React but just as powerful imho.

MartinZeltin left a reply on Not Getting Any Results Back From A Raw Query

I finally found a solution. It looks like the way I was doing it, I was passing in a single value to WHERE IN. So I remade it like so

$replies = DB::connection('second')
       ->table('sms_sender_inbox_replies')
       ->select('id', 'reply_text', 'sending_time')
       ->whereIn('phone_number', $phone_numbers)
       ->whereIn('id', DB::connection('second')
                         ->table('sms_sender_inbox_replies')
                         ->selectRaw('MAX(id)')
                         ->groupBy('phone_number'))
       ->get();

MartinZeltin left a reply on Not Getting Any Results Back From A Raw Query

P.S. Here is the output of the Query Log

I can't understand why it is returning an empty array.

Array
(
  [0] => Array
    (
      [query] => 
          SELECT id, reply_text, sending_time
          FROM sms_sender_inbox_replies
          WHERE phone_number IN (':phone_numbers')
          AND id IN (
              SELECT MAX(id)
              FROM sms_sender_inbox_replies
              GROUP BY phone_number
          )
                   
      [bindings] => Array
          (
              [phone_numbers] => +1234567819','+19873216154','+15984989898
          )

        [time] => 0.7
    )
)

MartinZeltin started a new conversation Not Getting Any Results Back From A Raw Query

Hello, I have a raw query and when I run this query in phpMyAdmin it returns 3 results but when I try to use Laravel Query Builder I get an empty array.

My query

SELECT id, reply_text, sending_time
FROM sms_sender_inbox_replies
WHERE phone_number
IN ('+1234567819',  '+19873216154',  '+15984989898')
AND id IN (
    SELECT MAX( id ) 
    FROM sms_sender_inbox_replies
    GROUP BY phone_number
)

Result:

+----+-----------------+---------------------+
| id |   reply_text    |    sending_time     |
+----+-----------------+---------------------+
| 87 | This is a test  | 2019-07-30 08:25:26 |
| 54 | And another one | 2019-07-29 06:35:11 |
| 12 | Last test       | 2019-06-16 09:44:26 |
+----+-----------------+---------------------+

But when I try to do this query with Laravel I get back an empty array []

dump($phone_numbers);

// 0 => "+1234567819"
// 1 => "+19873216154"
// 2 => "+15984989898"

$phone_numbers = implode("','", $phone_numbers);
dump($phone_numbers);


// +1234567819','+19873216154','+15984989898


dump("SELECT id, reply_text, sending_time
                  FROM sms_sender_inbox_replies
                  WHERE phone_number IN ('$phone_numbers')
                  AND id IN (
                      SELECT MAX(id)
                      FROM sms_sender_inbox_replies
                      GROUP BY phone_number
                  )");


// SELECT id, reply_text, sending_time
// FROM sms_sender_inbox_replies
// WHERE phone_number
// IN ('+1234567819',  '+19873216154',  '+15984989898')
// AND id IN (
//  SELECT MAX( id ) 
//  FROM sms_sender_inbox_replies
//  GROUP BY phone_number
// )



$replies = DB::connection('second_connection')
             ->select("
                  SELECT id, reply_text, sending_time
                  FROM sms_sender_inbox_replies
                  WHERE phone_number IN (':phone_numbers')
                  AND id IN (
                      SELECT MAX(id)
                      FROM sms_sender_inbox_replies
                      GROUP BY phone_number
                  )
             ", ['phone_numbers' => $phone_numbers]);

dump($replies);

// []

MartinZeltin left a reply on Question About Vuejs

Why can't you accomplish them with Vue?

Can you paste your routes and controller method that renders the view so we can take a look at it?

MartinZeltin left a reply on Call To A Member Function ToSql() On Array

It gave me this kind of query

 [query] => 
   SELECT id, reply_text, sending_time
   FROM inbox_replies
   WHERE number IN (':numbers')

but I was hoping to get a raw sql like this

   SELECT id, reply_text, sending_time
   FROM inbox_replies
   WHERE number IN ('123', '456', '789')

MartinZeltin left a reply on Getting Data From Another Website Using Axios

I have used JSONP before but it is only for GET requests.

$.getJSON("https://www.website.com?callback=?", function(json) {
    console.log(json);
});

MartinZeltin left a reply on Question About Vuejs

Hi, could you give more explanation as to what exactly you are trying to achieve?

MartinZeltin left a reply on Call To A Member Function ToSql() On Array

I get this error

Method Illuminate\Support\Collection::toSql does not exist

MartinZeltin left a reply on Call To A Member Function ToSql() On Array

When I have bindings for my SQL query, I would like to see the query that was executed with bindings

MartinZeltin started a new conversation Call To A Member Function ToSql() On Array

Hello, I am trying to use the toSql() function for Query Builder but it is not working. I get an error

Call to a member function toSql() on array

Here is my query

$replies = DB::connection('second_connection')
            ->select("
                 SELECT id, reply_text, sending_time
                 FROM inbox_replies
            ");

dump($replies->toSql());

It works on Eloquent but not for raw DB query like this. What am I doing wrong here?

21 May
3 months ago

MartinZeltin started a new conversation LeftJoinSub() Inside Another Left Join Subquery?

Is it possible to put a left join subquery inside another left join subquery using Eloquent?

For example, I have this query that I would like to re-write using Eloquent and without using Raw.

I know only how to do one level leftJoinSub().

select
    contracts.id,
    payments.ink_id,
from contracts
    left join (
        select
            contracts.id,
            payments.ink_id,
        from
            contracts
        left join (
            select
                ink_id,
            from
                payments
            group by
                ink_id
        ) payments on payments.ink_id = contracts.id
    ) as payments on contracts.id = payments.ink_id
20 May
4 months ago

MartinZeltin left a reply on How To Pass A Variable To A Function With Callback?

@KUNDEFINE - Yes!!! Thank you! That's what I was looking for! Like Snapey said, it's hard to find something when you don't know what to search for.

function doIt($data, $callback) {
    $callback($data);
}


doIt('my data', function($data) {
    echo 'Anonymous function: ' . $data;
});
19 May
4 months ago

MartinZeltin left a reply on How To Pass A Variable To A Function With Callback?

@SNAPEY - I got it to work. However I have seen code without the use keyword like this. How do they do it?

function doIt($callback) { 
    $callback(); 
}

$data = 'my data here...';

doIt(function($data) {
    echo 'Anonymous function!' . $data;
});

This is giving me these errors:

WARNING Missing argument 1 for {closure}(), called in /home4/phptest/public_html/code.php70(5) : eval()'d code on line 4 and defined on line number 9

NOTICE Undefined variable: data on line number 10

MartinZeltin left a reply on How To Pass A Variable To A Function With Callback?

@SNAPEY - Hmm, still getting an error


NOTICE Undefined variable: data on line number 7

WARNING Missing argument 1 for {closure}(), called in /home4/phptest/public_html/code.php70(5) : eval()'d code on line 4 and defined on line number 7
Anonymous function!

Code:

function doIt($callback) { 
    $callback(); 
} 

doIt(function($data) use ($data) {
    echo 'Anonymous function!' . $data;
});

MartinZeltin started a new conversation How To Pass A Variable To A Function With Callback?

I could not find anywhere how to pass a variable to my function that uses a callback.

This is giving me an error

NOTICE Undefined variable: data on line number 2
function doIt($callback) { 
    $callback($data); 
}


doIt(function($data) {
    echo 'Anonymous function: ' . $data;
}); 
15 May
4 months ago

MartinZeltin left a reply on What Does Double Colon :: Mean In View()?

@CRONIX - Oh, thanks. I was looking at the views docs but I found the answer in the Package Dev docs.

https://laravel.com/docs/5.8/packages#views

Package views are referenced using the package::view syntax convention. So, once your view path is registered in a service provider, you may load the admin view from the courier package like so:

Route::get('admin', function () {
    return view('courier::admin');
});

MartinZeltin left a reply on What Does Double Colon :: Mean In View()?

@CRONIX - I know about that. But isn't view() syntax like 'folder.view' instead of 'folder::layout'?

MartinZeltin started a new conversation What Does Double Colon :: Mean In View()?

I came across an interesting syntax when looking at the Laravel Telescope source code. I noticed a double colon in view. And I couldn't find anything about it in the Docs. What does double colon mean and how does it work?

I see that the layout view is located in telescope/resources/views/layout.blade.php

public function index()
    {
        return view('telescope::layout', [
            'cssFile' => Telescope::$useDarkTheme ? 'app-dark.css' : 'app.css',
            'telescopeScriptVariables' => Telescope::scriptVariables(),
        ]);
    }

https://github.com/laravel/telescope/blob/2.0/src/Http/Controllers/HomeController.php

14 May
4 months ago

MartinZeltin left a reply on Laravel Telescope Not Working On A Fresh Install (wrong Path)

I finally found a solution (for anyone else who might come across this issue).

  1. Open: \vendor\laravel\telescope\resources\views\layout.blade.php
  2. Change these lines
<!-- Global Telescope Object -->
<script>
   window.Telescope = @json($telescopeScriptVariables);
</script>

to this

<!-- Global Telescope Object -->
<script>
   window.Telescope = @json($telescopeScriptVariables);
   window.Telescope.path = 'your_project_folder/public/telescope';
</script>

MartinZeltin started a new conversation Laravel Telescope Not Working On A Fresh Install (wrong Path)

I installed a fresh Laravel 5.8 with composer create-project --prefer-dist laravel/laravel larascopy

I can access it by going to: http://localhost/larascopy/public/

And then installed Telescope with these commands from the Guide:

composer require laravel/telescope
php artisan telescope:install
php artisan migrate

Then I can open Telescope like this http://localhost/larascopy/public/telescope

But all the links are wrong! They are pointing to: http://localhost/telescope/...

So I get all these errors in Console..

POST http://localhost/telescope/telescope-api/commands?tag=&before=&take=50&family_hash= 404 (Not Found)
POST http://localhost/telescope/telescope-api/commands?tag=&before=&take=50&family_hash= 404 (Not Found)
POST http://localhost/telescope/telescope-api/schedule?tag=&before=&take=50&family_hash= 404 (Not Found)
app.js?id=8776cf12ba6d7c72f145:1 Uncaught (in promise) Error: Request failed with status code 404
08 May
4 months ago

MartinZeltin started a new conversation What Is Query() Method For?

I have noticed in a project a syntax like this but I could not find it on the Laravel docs anywhere. What is this syntax and why is it necessary?

class Email extends Model
{
    public function getEmails()
    {
        return self::query()
            ->where('id', 89)
            ->where('email', '[email protected]')
            ->get();
    }
}

Isn't it the same as this? What is the query() for?

class Email extends Model
{
    public function getEmails()
    {
        return self::where('id', 89)
            ->where('email', '[email protected]')
            ->get();
    }
}

MartinZeltin left a reply on How To Run A Command On A Specific Day At 9:00 Am?

@MTHOMAS - Perfect, I missed that part from the docs!

$schedule->command('ml:audits on')
                 ->dailyAt('15:55')
                 ->when(function() {
                     return date('Y-m-d') == '2019-05-08';
                 });

MartinZeltin started a new conversation How To Run A Command On A Specific Day At 9:00 Am?

I looked at the schedule command for Laravel and it allows to execute a command every hour, on monday etc.

But I could not find a way to execute a command only once for example On July 4th, 2019 at 9:00 am.

07 May
4 months ago

MartinZeltin left a reply on Vuejs Components In App.js And In .blades

This worked for me but without using webpack. Just native ES6.

{
    path: '/',
    component: () => import('./MyComponent.js')
}

MartinZeltin left a reply on HTML Array Not Work With Table

@SANJAYACLOUD - I'm not sure I understand what is needed. Could you give an example of the result and what you are getting?

06 May
4 months ago

MartinZeltin left a reply on HTML Array Not Work With Table

It creates the array properly for me, check out this fiddle

http://sandbox.onlinephpfunctions.com/code/018165f249c7cf37afde77ffe3f62d90bd87330e

<?php

function storeInvoice()
{
    $answersArray = array();
    $i = 1;
    
    $request['product'][] = 1;
    $request['product'][] = 2;
    
    foreach($request['product'] as $answer)
    {
        $answersArray[$i] = $answer;
        $i++;
    }
    
    return $answersArray;
}


print_r(storeInvoice());

MartinZeltin left a reply on How Can I Create Relationship Between Tables In Laravel And Page Limit Depending On User Roles

Could you post your 2 tables and their common column how they are related? And what error are you getting when creating the relationship in your Model?

P.S. You can use something like this to generate tables https://www.tablesgenerator.com/text_tables