phoenixg

phoenixg

Member Since 4 Years Ago

Experience Points
2,010
Total
Experience

2,990 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
9
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 1
2,010 XP
16 Aug
1 month ago

phoenixg started a new conversation How To Convert This SQL(get Latest 3 Record By Group) Into Eloquent Query?

select * from media as dm1
    where (
      select count(dm2.dm_media_id) from media as dm2 
      where dm2.dm_type = dm1.dm_type and dm2.dm_created_at > dm1.dm_created_at
    ) < 3 and dm_app_id = 'abc' order by dm_created_at desc;
25 Jul
1 month ago

phoenixg started a new conversation How Do I Prevent Loading Non-related Third-party And Custom-components When Visit Home And Specific Resource Page?

Nova loads too much, why it needs to load them when I visit non-related page at all.

04 Jun
3 months ago

phoenixg started a new conversation How Can I Add Iframe Card In Nova?

I don't want iframe field, I want iframe card.

28 May
3 months ago

phoenixg left a reply on Hey, Is There A Way To Manually Reload Resource In My Custom Cards.vue?

@DEVFREY - How to do that? I don't want to refresh the page

26 May
3 months ago

phoenixg started a new conversation Hey, Is There A Way To Manually Reload Resource In My Custom Cards.vue?

Hey, is there a way to manually reload resource in my custom cards.vue?

22 May
3 months ago

phoenixg left a reply on Is It Possible That Nova Lens Automatically Apply The Resource Filter?

@DEVFREY - My lens filter is equal to resource filter, so I don't want to select filter again in my lens

phoenixg left a reply on Is It Possible That Nova Lens Automatically Apply The Resource Filter?

    public static function query(LensRequest $request, $query)
    {
// how do I  get the current resource $request, in order to apply the resource's filter to lens

        return $request->withOrdering($request->withFilters(
            $query->select(DB::raw("DATE_FORMAT(date, '%Y-%m') as month, 
                sum(num) as num
                "))
                ->groupBy('month')
                ->orderByDesc('month')
        ));
    }

phoenixg started a new conversation Is It Possible That Nova Lens Automatically Apply The Resource Filter?

When come into lens, I want to automatically apply the resource filter.

26 Apr
4 months ago

phoenixg started a new conversation How Many People Are Maintaining Nova?

It seems the upgrade schedule is not rigid and upgrade progress is slow.

11 Apr
5 months ago

phoenixg left a reply on How Do I Rewrite Such Sql Into Eloquent Style?

@STAUDENMEIR -

$app_id = 'app001';
$order_no = '11111';
$sql = "(
                select ch_id from Charge 
                    where ch_order_no = :id and ch_app_id = 'app001'
                union all
                select ch_id from Charge
                    where ch_id = :id and ch_app_id = 'app001'
            ) as " . Charge::db()->getTablePrefix() . "t";
$queryCount = Charge::db()->table(Charge::db()->raw(str_replace('\n', ' ', $sql)))->setBindings(['id' => $test]);
var_dump($queryCount->count());

$sql1 = Charge->select(Charge::db()->raw('ch_id'))
    ->whereRaw(Charge::db()->raw("ch_order_no = ':order_no'"))
    ->whereRaw(Charge::db()->raw("ch_app_id = ':app_id'"))
    ->setBindings(['order_no' => $order_no, 'app_id' => $app_id]);
$sql2 = Charge::multiwhere([])
    ->select(Charge::db()->raw('ch_id'))
    ->whereRaw(Charge::db()->raw("ch_id = ':order_no'"))
    ->whereRaw(Charge::db()->raw("ch_app_id = ':app_id'"))
    ->setBindings(['order_no' => $order_no, 'app_id' => $app_id]);
$count = $sql1->unionAll($sql2)->count();

Not working

02 Apr
5 months ago

phoenixg started a new conversation How Do I Rewrite Such Sql Into Eloquent Style?

$sql = "(
                select ch_id from Charge 
                    where ch_order_no = :id and ch_app_id = 'app_id'
                union all
                select ch_id from Charge
                    where ch_id = :id and ch_app_id = 'app_id'
            ) as " . Charge::db()->getTablePrefix() . "t";
$queryCount = Charge::db()->table(Charge::db()->raw(str_replace('\n', ' ', $sql)));
var_dump($queryCount->count());
21 Feb
6 months ago

phoenixg started a new conversation How To Integrate Nova With Swoole?

When I'm using swooletw/laravel-swoole pacakge, something just broken, not working very well, is there a best solution here?

14 Feb
7 months ago

phoenixg left a reply on Database Cannot Select Correct After Upgrading Nova To V1.3.1 From V1.3.0

Solved after upgrade from v1.3.1 to v1.3.2.

11 Feb
7 months ago

phoenixg started a new conversation Database Cannot Select Correct After Upgrading Nova To V1.3.1 From V1.3.0

Base table or view not found 1146: adm.mytable .... doesn't exist. error occurred.

Actually , before I use v1.3.1, it's all OK, my default database connection is adm not dash, but this mytable is in dash. But why it cannot locate to the correct database connection after upgrading to v1.3.1?

I use protected static $connection_name='dash'; in base model class to specify the connection.

01 Feb
7 months ago

phoenixg started a new conversation What's The Best Solution For Laravel Implementing Swoole?

Laravel with swoole

20 Dec
9 months ago

phoenixg started a new conversation Nova Avatar Field Not Display Correct URL

# In resource
Avatar::make('avatar') ->thumbnail(new NovaUserAvatar($this))->exceptOnForms() 

# In NovaUserAvatar:
    public function __invoke()
    {
        return 'https://static.dingtalk.com/media/image-avatar.jpg';
    }

Why it renders out: http://nova.local/storage/https://static.dingtalk.com/media/image-avatar..jpg

How to remove the prepended http://nova.local/storage/?

05 Dec
9 months ago

phoenixg started a new conversation How To Overwrite Laravel Telescope View Layout?

I want to use my own telescope layout which extends the default one under vendor/laravel/telescope/resources/views/layout.blade.php

26 Nov
9 months ago

phoenixg started a new conversation Do I Need Run `queue:work` When I'm Using Horizon?

Do I have to run queue:work when I'm using horizon?

20 Nov
10 months ago

phoenixg started a new conversation How To Change My Nova Action To Queue When I Write Code Not A Model Loop?

// /my-nova/app/Nova/Actions/RerunTiCharge2Hour.php
// Here is the handle() method
public function handle(ActionFields $fields, Collection $models)
    {
        set_time_limit(0);

        $runList = [];
        foreach ($models as $model) {
            if (isset($runList[$model->date->toDateString()])) {
                $runList[$model->date->toDateString()][] = $model->app_id;
            } else {
                $runList[$model->date->toDateString()] = [$model->app_id];
            }

            $runList[$model->date->toDateString()] = array_unique($runList[$model->date->toDateString()]);
        }

        foreach ($runList as $date => $appIdList) {
            foreach ($appIdList as $appId) {
                Artisan::call('cmd-ticharge2hour:run', [
                    'date' => $date,
                    'app_id' => $appId,
                ]);
            }
        }

        return Action::message('Finished');
    }

25 Oct
10 months ago

phoenixg started a new conversation Telescope Composer Install Error

I've installed telescope using --dev, but when I run composer install --no-dev, it occurred error:

[[email protected] pingpp-nova]# composer install --no-dev
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Installing dependencies from lock file
Nothing to install or update
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
PHP Fatal error:  Class 'Laravel\Telescope\TelescopeApplicationServiceProvider' not found in /data/ppp/phx-nova/app/Providers/TelescopeServiceProvider.php on line 10

In Container.php line 779:

  Class auth does not exist

How to solve this?

15 Oct
11 months ago

phoenixg left a reply on How To Change Nova Action Select Name To My Own Word?

I defined a $name property and it works too.

phoenixg started a new conversation Where Can I Write A Method Which Execute Every Nova Resource Has Responsed To The Frontend?

like I'm going to implement a logging method after each Nova request.

07 Oct
11 months ago

phoenixg left a reply on General Error: 1205 Lock Wait Timeout Exceeded In Nova Action

@Tray2 How do I should use NOWAIT SKIPPED LOCKED in my situation?

06 Oct
11 months ago

phoenixg started a new conversation General Error: 1205 Lock Wait Timeout Exceeded In Nova Action

Here is my error stack:

[2018-10-07 10:41:07] local.ERROR: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction (SQL: update `nova_action_events` set `status` = finished, `updated_at` = 2018-10-07 10:40:16 where `batch_id` = 8bf5d7ab-45b1-4c48-aff8-5ae54080701b and `status` not in (finished, failed)) {"userId":"07166164102539","email":"[email protected]","exception":"[object] (Illuminate\Database\QueryException(code: HY000): SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction (SQL: update `nova_action_events` set `status` = finished, `updated_at` = 2018-10-07 10:40:16 where `batch_id` = 8bf5d7ab-45b1-4c48-aff8-5ae54080701b and `status` not in (finished, failed)) at /Users/phx/mine/projects/php/my-nova/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, Doctrine\DBAL\Driver\PDOException(code: HY000): SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction at /Users/phx/mine/projects/php/my-nova/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:144, PDOException(code: HY000): SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction at /Users/phx/mine/projects/php/my-nova/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:142)
[stacktrace]
#0 /Users/phx/mine/projects/php/my-nova/vendor/laravel/framework/src/Illuminate/Database/Connection.php(624): Illuminate\Database\Connection->runQueryCallback('update `nova_ac...', Array, Object(Closure))
#1 /Users/phx/mine/projects/php/my-nova/vendor/laravel/framework/src/Illuminate/Database/Connection.php(490): Illuminate\Database\Connection->run('update `nova_ac...', Array, Object(Closure))
#2 /Users/phx/mine/projects/php/my-nova/vendor/laravel/framework/src/Illuminate/Database/Connection.php(423): Illuminate\Database\Connection->affectingStatement('update `nova_ac...', Array)
...
#83 /Users/phx/mine/projects/php/my-nova/public/index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#84 {main}
"} 

Here is my Action

<?php

namespace App\Nova\Actions;

use App\Traits\EloquentBootstrap;
use Artisan;
use Illuminate\Bus\Queueable;
use Laravel\Nova\Actions\Action;
use Illuminate\Support\Collection;
use Laravel\Nova\Fields\ActionFields;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Laravel\Nova\Fields\Text;

class RerunTheScript extends Action
{
    use InteractsWithQueue, Queueable, SerializesModels;

    use EloquentBootstrap;

    public $name = 'Rerun the script';

    public function handle(ActionFields $fields, Collection $models)
    {

        $this->bootEloquent();
        return Action::message('success');
    }

}

Here is my trait:

namespace App\Traits;
use App\Utils\Encryption\Encryption;
use Illuminate\Container\Container;
use Illuminate\Events\Dispatcher;
use Illuminate\Database\Capsule\Manager as Capsule;

trait EloquentBootstrap
{
    public function bootEloquent()
    {
        $capsule = new Capsule;

        $capsule->setAsGlobal();

        $capsule->setEventDispatcher(new Dispatcher(new Container));

        foreach (config('database.connections') as $connection => &$db) {
            $capsule->addConnection($db, $connection);
            Capsule::connection($connection)->enableQueryLog();
        }

        $capsule->bootEloquent();
    }
}

If I remove the trait, that's OK, but I have to use the manually eloquent booter, because my Eloquent models are a standalone composer project.

How to solve that?

phoenixg started a new conversation How To Change Nova Action Select Name To My Own Word?

How to change Nova Action select name to my own word?

05 Oct
11 months ago

phoenixg left a reply on How To Deploy Nova?

@samo So am I supposed to add /public/vendor/nova and /resources/lang/vendor/nova and /resources/views/vendor/nova/partials to .gitignore file?

phoenixg started a new conversation Where Am I Supposed To Write My Own CSS In Nova?

Here is the default file structure:

img

29 Sep
11 months ago

phoenixg started a new conversation How To Deploy Nova?

After I run composer install --no-dev and yarn run productionunder the Laravel project root directory, what else should I run to deploy nova? Seem's there are some other NPM things to install.

28 Sep
11 months ago

phoenixg left a reply on How To Add A Where Clause For A Resource By Default?

@burlresearch It works. But I feel it too complicated, and overwriting default all() makes is always need to run withoutGlobalScope to avoid.

27 Sep
11 months ago

phoenixg started a new conversation How To Add A Where Clause For A Resource By Default?

When open a resource I want to modify the query by adding a where clause or something by default.

25 Sep
11 months ago

phoenixg started a new conversation How Can I Overwrite Nova's LoginController Using My Own?

I want to login by socialite

20 Sep
1 year ago

phoenixg started a new conversation How To Apply Default Nova Order By Field When Open A Nova Resource?

And, I also want to know how to sort by clicking a field default using desc first, not asc first.

phoenixg started a new conversation How To Always Apply A Default Nova Filter When Open A Resource?

I can't find it one the document.

19 Sep
1 year ago

phoenixg started a new conversation What's The Difference Between Nova:base-resource, Nova:resource, Nova:resource-tool And Nova:tool?

By the way, if I want to build a page with a nav bar and a table content which retrieve data from 3rd API, which one should I choose?

phoenixg left a reply on How Can I Overwrite Laravel Nova's Layout View?

@bernhardh But if the origin blade file changed, I would re-publish that?

18 Sep
1 year ago

phoenixg started a new conversation How To Render Simply A Table In Nova By Response From API Not A Resource From Db?

I would like to fetch a json response and render as a table, meanwhile, I want that to have lense, cards, and actions feature as well.

17 Sep
1 year ago

phoenixg started a new conversation How Can I Overwrite Laravel Nova's Layout View?

I found it's all under /nova folder, but when I upgrade, I would not know how many file has been changed. So I cann't modify files under that folder.

Also, I want to know if I installed a nova component package, how should I overwrite it's layout.

11 Sep
2 years ago

phoenixg started a new conversation How To Write Sub-query Inner Join With Chunk Using Laravel Eloquent Syntax? Ask Question

I have this SQL now:

SELECT `trans_id`,
       `trans_subject`,
       `trans_paid_time`,
       `trans_amount`
FROM `transaction`
WHERE `trans_app_id` = 'app_123'
  AND `trans_paid_time` >= '2017-08-01 00:00:00'
  LIMIT 5000 OFFSET 55000;

My code currently is:

Transaction::where('trans_app_id', 'app_123')
    ->where('trans_paid_time', '>=', '2017-08-01 00:00:00')
    ->select(['trans_id', 'trans_subject', 'trans_paid_time'])
    ->chunk(5000, function ($transactions)  {
        $transactions->each(function ($transaction) use ($instance) {
            // do something with $transaction
        });
    });

But I'm planning to turn this SQL into below SQL:

SELECT `trans_id`,`trans_subject`,`trans_paid_time`, `trans_amount`
FROM transaction
INNER JOIN
  (SELECT trans_id
   FROM transaction
   WHERE`trans_app_id` = 'app_123'
     AND `trans_paid_time` >= '2017-08-01 00:00:00'
   ORDER BY trans_paid_time 
   LIMIT 125000, 5000) AS lim 
 using(trans_id);

How should I convert my Eloquent code?