Конечно поздно, но может другим понадобится. Если я правильно понял, то тебе нужно что то такое
$query = \DB::table('название таблицы');
$query->where('что то сравниваешь', 'с чем то сравниваешь');
$query->groupBy('id')->get();
Конечно поздно, но может другим понадобится. Если я правильно понял, то тебе нужно что то такое
$query = \DB::table('название таблицы');
$query->where('что то сравниваешь', 'с чем то сравниваешь');
$query->groupBy('id')->get();
Для виндовса (например если тестирование на локалке на винде проходит)
This is possible with Windows Task Scheduler but the downside is the lowest it can be set to is Every 5 Minutes which is still ok for a testing environment.
I created a batch file scheduler.bat with the following contents
PHPcd c:\lamp\www\cw5
PHPC:\lamp\bin\php\php-5.6.3\php.exe artisan schedule:run 1>> NUL 2>&1
.
Change directorys to match your setup. My project root is cw5
If you have php successfully added to your PATH variable then the second line can read php artisan..... no need for an exact location. But you will need to make sure you cd to your project root first.
Then launch the task scheduler Windows Key + R then paste in Taskschd.msc and hit enter.
Then click Create Basic Task on the right in the Actions pane.
Name your task something so you will know what it is for if you need to modify it or are running multiple projects then click Next.
Leave this page set to Daily for now and click Next.
Leave this page as defaults as well and click Next.
Make sure Start a Program is selected and click Next.
Browse to the batch file we just created and then click Next then click Finish.
Now, select Task Scheduler Library on the left, and find your task in the middle pane and right-click and click Properties
Go to the Triggers tab, click Daily in the list and click Edit.
The drop-down at the top next to Begin the task change to At Log on for Any user
Check the box that says Repeat Task Every and choose 5 Minutes from the drop-down. The drop-down after for a duration: on the same line choose Indefinitely.
Click OK. Done.
Then right-click on your task in the middle pane and click Run to initiate it.
Для меня. Ибо достало путаться.
class Post extends Model {
public function comments(){
return $this->hasMany('App\Comment', 'id_в_таблице_комментов', 'id_в_таблице_постов');
}
}
class Comment extends Model {
public function post(){
return $this->belongsTo('App\Post', 'id_в_таблице_комментов', 'id_в_таблице_постов');
}
}