$data = HistoryWeightRecord::get();
$date = [];
foreach ($data as $allDate) {
$date[] = Carbon::parse($allDate->datetime)->format('Y-m-d');
}
$uniqueDate = collect($date)->unique();
$uniqueEquipment = $data->unique('equipment_id');
$sumArr = [];
foreach ($uniqueEquipment as $eqId) {
foreach ($uniqueDate as $day) {
$sum = HistoryWeightRecord::whereDate('datetime', $day)->where('equipment_id', $eqId->equipment_id)->sum('mass');
$sumArr[$eqId->equipment_id][$day] = $sum;
};
}
return $sumArr;
$response = $this->get('/api/works/show/1');
$response
->assertJson(fn (AssertableJson $json) =>
$json->has('status')
->has('message')
->has('data.work', fn ($json) =>
$json->where('time_end', '19:59')
->etc()
)
);
public function handle(Request $request, Closure $next)
{
$routeName = $request->route()->getAction()['as'];
$routeDescription = [
post.index => 'Просмотр списка постов',
post.create => 'Вызвал форму для создания поста',
post.store => 'Создал пост',
];
if (array_key_exists($routeName, $routeDescription)) {
$a = $routs[$routeName];
UserLog::create([
'date' => '2021-08-25',
'user_id' => 2,
'action' => $a,
]);
}
return $next($request);
}
public function destroy(Request $request)
{
$idle = Idle::find($request->get('id'));
if ($idle !== null) {
$idle->delete();
return $this->responseRepository->Response($idle, true, 'Запись с таким id удалена');
}
return $this->responseRepository->Response('Запись с таким id не обнаружена');
}
public static function Response($message = "Ошибка", $data = null, $status = false)
{
return response()->json([
'status' => $status,
'message' => $message,
'data' => $data,
]);
}
public function index(Request $request)
{
$limit = $request->get('limit');
$tags = $request->get('tags');
$array_tag = explode(",", $tags);
$employes = Employe::query()
->when($array_tag, function($q) use ($array_tag){
$q->whereHas('tags', function($q) use ($array_tag) {
$q->whereIn('tag_id', $array_tag);
});
})->paginate($limit);
return $employes;
}
<form action="{{ (empty($cats) ? route('category.store') : route('category.update', ['id'=>$cats->id])) }}" method="post" enctype="multipart/form-data">
@csrf
@if (isset($cats))
@method('PATCH')
@endif
<div class="form-group">
<label for="cat_id">Категория</label>
{{$cats->tite ?? ''}}
</div>
<div class="form-group">
<input name="category[title]" type="text" class="form-control" required value="{{ $cats->title ?? ''}}">
</div>
<input type="submit" value="Создать" class="btn btn-outline-success">
</form>
Schema::create('categories_roles', function (Blueprint $table) {
$table->bigInteger('category_id')->unsigned();
$table->bigInteger('role_id')->unsigned();
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
$table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade');
$table->primary(['category_id', 'role_id']);
$table->timestamps();
});
AssociationField::new('tags')->setFormTypeOptions([
'by_reference' => false,
]),
<div class="container bg-light">
{% for posts in post %}
<div class="row border-bottom pb-2 pt-2">
<div class="col-md-3"><img src="{{ vich_uploader_asset(posts) }}" class="d-flex mr-3 img-thumbnail" alt="{{ posts.thumbnailFile }}"></div>
<div class="col-md-9 pt-2">
<h4 class="mt-0 font-weight-bold"><a href="{{ path('single', {'post': posts.id }) }}">{{ posts.title }}</a></h4>
<p class="mb-0"><small><i class="far fa-calendar-alt pr-2"></i>{{ posts.createdAt|date("F jS \\a\\t g:ia") }}</small></p>
{% for tag in tags %}
<a href="#" class="btn btn-primary btn-sm active mt-4" role="button" aria-pressed="true">{{ tag }}</a>
{% endfor %}
</div>
</div>
{% endfor %}
const fs = require('fs');
const store = require('app-store-scraper');
store.search({
term: 'ninja',
num: 2,
page: 3,
country : 'us',
lang: 'lang'
})
.then(response => {
fs.writeFileSync('file.json', JSON.stringify(response));
})
.catch(err => {
fs.writeFileSync('file.json', JSON.stringify(err));
});