darkec

Experience

480

0 Best Reply Awards

  • Member Since 2 Years Ago
  • 0 Lessons Completed
  • 0 Favorites

14th June, 2018

darkec started a new conversation Does RefreshDatabase Rollback Changes After Each Test Of At The End Of All • 4 months ago

Let's say I have simple test with 2 functions:

public function testCreateUser()
{
    User::create(['username' => 'test']); 
}

And this is where I create a user and it has id=1.

Now I want to get that user in next test function

public function testGetUser()
{
    User::find(1); 
}

Will this user be in my database or will RefreshDatabase rollback my changes after it finishes with testCreateUser() so my user won't be saved in the database?

22nd August, 2017

darkec left a reply on Polymorphic Relation Returns Query Like "Is Null And Is Not Null" • 1 year ago

The problem was with this:

$this->homeStorages->storageLoads()->toSql();

I was taking all records and relations to it, but when I do this:

$this->homeStorages->find(1)->storageLoads()->toSql();

It works just fine

21st August, 2017

darkec started a new conversation Polymorphic Relation Returns Query Like "Is Null And Is Not Null" • 1 year ago

I created polymorphic relation and it works just fine, but when I query it I get query like this one:

select * from `storage_loads` 
where `storage_loads`.`storage_id` is null and `storage_loads`.`storage_id` is not null and `storage_loads`.`storage_type` = ?

The problem is this part

where `storage_loads`.`storage_id` is null and `storage_loads`.`storage_id` is not null 

This is my relation inside HomeStorages model

    public function storageLoads()
    {
        return $this->morphMany(env('KALA_API_RESOURCES_NAMESPACE') . 'StorageLoads\Model', 'storage');
    }

This is my query

$this->homeStorages->storageLoads()->toSql();

Why Laravel adds "is null and is not null"

7th August, 2017

darkec left a reply on Running Laravel Script Via CLI • 1 year ago

I'm on shared hosting and can't user Redis, this is just temporary solution I want to use, simple cron job

darkec started a new conversation Running Laravel Script Via CLI • 1 year ago

My script requires long execution, 5+ minutes. The best solution for me is to run my script via CLI, but which way is the best from Laravel's perspective.

  1. I read about Task Scheduling https://laravel.com/docs/5.4/scheduling which is a good solution since it is run via Cron Job and that is something I need. But is that script called as CLI command and does it have execution time?

  2. Second is https://laravel.com/docs/5.4/artisan#generating-commands my own command. Which is called via CLI and I can make it execute my script.

Which is better to take and keep in mind I need execution time to be almost unlimited

22nd June, 2017

darkec started a new conversation Limit On The WHERE Col IN (…) Condition • 1 year ago

When using relations in Laravel, queries are like:

SELECT * FROM table
WHERE Col IN (1,2,3,4,5...)

Did anyone encountered with the problem of it, I guess there must be a limit of ids within IN()

9th May, 2017

darkec left a reply on Debug = False Is Not Working • 1 year ago

I've tried all of that :/

darkec left a reply on Debug = False Is Not Working • 1 year ago

Still not working this is what I get

{
  "error": {
    "message": "Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ']'",
    "status_code": 500,
    "debug": {
      "line": 103,
      "file": "E:\\xampp\\htdocs\\app\\Api\\V1\\Controllers\\Messages\\MessageController.php",
      "class": "Symfony\\Component\\Debug\\Exception\\FatalThrowableError",
      "trace": [
        "#0 E:\\xampp\\htdocs\\vendor\\composer\\ClassLoader.php(322): Composer\\Autoload\\includeFile('E:\\\\xampp\\\\htdocs...')",
        "#1 [internal function]: Composer\\Autoload\\ClassLoader->loadClass('App\\\\Api\\\\V1\\\\Cont...')",
        "#2 [internal function]: spl_autoload_call('App\\\\Api\\\\V1\\\\Cont...')",
      ]
    }
  }
}

8th May, 2017

darkec left a reply on Debug = False Is Not Working • 1 year ago

Unfortunately not working

darkec left a reply on Debug = False Is Not Working • 1 year ago

they are from .env config/app.php is left as it is during installation

darkec started a new conversation Debug = False Is Not Working • 1 year ago

I set my .env as follows: APP_ENV=production APP_DEBUG=false APP_LOG_LEVEL=info

But it stills shows me debug messages and trace in API. Why is that?

5th May, 2017

darkec started a new conversation Logging/Debugging API • 1 year ago

Hi

Is there any way I can log/debug my APIs to see number of queries and similar logs. I tried with debugbar and ajax but it's not working. I've tried everything I could think of or find online, nothing is working.

Does anyone has a solution?

18th May, 2016

darkec started a new conversation Laravel Cache Dependency • 2 years ago

Hi In yii, we could use cache dependency. For example:

$sql = 'SELECT * FROM tbl_post LIMIT 20';
$dependency = new CDbCacheDependency('SELECT MAX(update_time) FROM tbl_post');  
$rows = Yii::app()->db->cache(1000, $dependency)->createCommand($sql)->queryAll();

And when query result be changed, the cache content will also change before expiration and then will send to output. How to do this job in the laravel? Is there any bundle for this task?

21st April, 2016

darkec left a reply on Validator::make • 2 years ago

Such simple solution, I was trying to "use" some different Validators, all I need to do is to "use Validator" before implementation of "class"

20th April, 2016

darkec left a reply on Validator::make • 2 years ago

This is what I get ErrorException in ApiAuthController.php line 116: Non-static method Illuminate\Validation\Factory::make() should not be called statically, assuming $this from incompatible context after Validator::make is called

darkec started a new conversation Validator::make • 2 years ago

What Validator is used here https://laravel.com/docs/5.0/validation when Validator::make is called?

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.