AppServiceProvider
public function boot(){
Validator::extend('count_books', function($attribute, $value, $parameters) {
$count = IssueBook::where('client_id', $value)->where('is_returned', false)->count()
return $count < 2;
});
}
StoreRequest
public function rules()
{
return [
'category_id' => 'exists:App\Category,id',
'client_id' => 'exists:App\Client,id|count_books',
'book_id' => 'exists:App\Book,id',
'days_issued' => 'nullable|string',
'is_returned' => 'nullable|boolean',
'return_date' => 'nullable|date',
];
}
return [
['full_name', 'contacts'],
['', 'type', 'name',],
];
$sheet->mergeCells('A1:B1');
select date, abs(sum-first_month_value)/2 from (select
sum(price) as sum,
count(date) as count,
date,
first_value(sum(price)) over() as first_month_value
from t
group by
date
order by date) as t;
WITH RECURSIVE r AS (
SELECT id, parent_id, name, 1 as level, parent_id as first_level
FROM geo
WHERE parent_id = 4
UNION
SELECT geo.id, geo.parent_id, geo.name, (r.level+1), r.first_level
FROM geo
JOIN r
ON geo.parent_id = r.id
)
SELECT * FROM r;
select * from table inner join (select a, b,c from table group by a, b, c having count(*) > 1) as t on t.a = table.a and t.b = table.b and t.c = table.c;
$order = Post::with(['comments' => function ($q){
$q->where('user_id',Auth::id());
}])->whereHas('comments',function ($q){
$q->where('user_id',Auth::id());
})->get();
select
year(date),
sum(`index`.`index`),
substring_index(group_concat(`index`.`index` order by date asc), ',', -1) as last
from
where id_uin = 4 and id_status = 5 group by year(date);
select
(select `index` from `index` where year(date) = '2018' and id_uin = 4 and id_status = 5 order by date desc limit 1 ) as '2018',
(select `index` from `index` where year(date) = '2019' and id_uin = 4 and id_status = 5 order by date desc limit 1 ) as '2019',
(select `index` from `index` where year(date) = '2020' and id_uin = 4 and id_status = 5 order by date desc limit 1 ) as '2020',
(select `index` from `index` where year(date) = '2021' and id_uin = 4 and id_status = 5 order by date desc limit 1 ) as '2021';
select
substring_index(group_concat(`2018`), ',', -1) as `2018`,
substring_index(group_concat(`2019`), ',', -1) as `2019`,
substring_index(group_concat(`2020`), ',', -1) as `2020`,
substring_index(group_concat(`2021`), ',', -1) as `2021`
from (SELECT
CASE WHEN date BETWEEN '2018-01-01' AND '2018-12-31' THEN `index` ELSE null END AS `2018`,
CASE WHEN date BETWEEN '2019-01-01' AND '2019-12-31' THEN `index` ELSE null END AS `2019`,
CASE WHEN date BETWEEN '2020-01-01' AND '2020-12-31' THEN `index` ELSE null END AS `2020`,
CASE WHEN date BETWEEN '2021-01-01' AND '2021-12-31' THEN `index` ELSE null END AS `2021`
FROM `index`
WHERE id_uin = 4 and id_status = 5
GROUP BY `2018`, `2019`, `2020`, `2021`) as t;
echo hash('sha1', "{\"order_id\": \"FACTPRECHR152632\", \"amount\": \"8300.00\"}".'9fff8c602b08b00323567be0001480f6');
$factory->createBrowser(['proxyServer' => '127.0.0.1:8080']);