Skip to content

Instantly share code, notes, and snippets.

View shreesubhendu's full-sized avatar
🎯
Focusing

Subhendu Kumar Giri shreesubhendu

🎯
Focusing
  • New Delhi
  • 15:47 (UTC +05:30)
View GitHub Profile
@shreesubhendu
shreesubhendu / Check whether record exists in, DB Laravel
Last active January 23, 2020 13:46
Check whether record exists in, DB Laravel
// If you want to use the Model object if it exists:
$model = Model::where('column', '=', Input::get('column'))->first();
if ($model === null) {
// Model doesn't exist
}
// If only to check if exist or not
if (Model::where('column', '=', Input::get('column'))->count() > 0) {
// Model found
}
@shreesubhendu
shreesubhendu / Ajax post Laravel
Created January 23, 2020 13:33
Ajax post Laravel
<script>
$(".add").click(function () {
var data = $('#form').serializeArray();
data.push({name: '_token', value: $('input[name=_token]').val()});
$.ajax({
type: 'POST',
url: 'ajaxmovies',
data: data,
success: function (data) {
toastr.success('Successfully added Module!', 'Success Alert', {timeOut: 5000});
<IfModule mod_headers.c>
Header set Referrer-Policy "origin"
Header set Access-Control-Allow-Origin 'https://cdn.ampproject.org'
Header set AMP-Access-Control-Allow-Source-Origin 'https://yoursite.com'
</IfModule>
@shreesubhendu
shreesubhendu / gist:f9ada64f165fc69c0786339d59d2c79f
Created March 10, 2020 16:59
Last day of given month and year and last day of previous month in PHP
$current_month = 3;
$current_year = 2020;
//first day of previous month from given month and year
$firstDayOfLastMonth = date_create($current_year.'-'.$current_month.'-01 first day of last month')->format('Y-m-d');
//last day of previous month from given month and year
$lastDayOfLastMonth = date_create($current_year.'-'.$current_month.'-01 last day of last month')->format('Y-m-d');
//first day of given month and year
@shreesubhendu
shreesubhendu / Laravel 3column from eloquent
Created December 20, 2021 13:30
Laravel 3column from eloquent
@foreach ($data->chunk(3) as $row)
<div class="row">
@foreach ($row as $s)
<div class="col-md-4 col-xs-12">
...
</div>
@endforeach
</div>
@endforeach
/**
* Get Youtube id from the URL
* Some examples are
* https://youtube.com/shorts/dQw4w9WgXcQ?feature=share
* //www.youtube-nocookie.com/embed/up_lNV-yoK4?rel=0,
* http://www.youtube.com/user/Scobleizer#p/u/1/1p3vcRhsYGo
* http://www.youtube.com/watch?v=cKZDdG9FTKY&feature=channel
* http://www.youtube.com/watch?v=yZ-K7nCVnBI&playnext_from=TL&videos=osPknwzXEas&feature=sub
* http://www.youtube.com/ytscreeningroom?v=NRHVzbJVx8I