Skip to content

Instantly share code, notes, and snippets.

Vineeth Vijayan vineeth030

Block or report user

Report or block vineeth030

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View query-scope-method
// Add scope methods in model class
public function scopeConditionOne($query)
{
return $query->where('column_1', '=', 100);
}
public function scopeConditionTwo($query)
{
return $query->where('column_2', '=', 100);
}
View where-conditions-as-array
$conditions = [
['column_1', '=', 100],
['column_2', '=', 100],
['column_3', '=', 100],
['column_4', '=', 100],
['column_5', '=', 100]
];
$query->where($conditions)->get();
View long-list-where
$results = User::where('column_1', '=', 100)
->where('column_2', '=', 100)
->where('column_3', '=', 100)
->where('column_4', '=', 100)
->where('column_5', '=', 100)
->get();
View seeder-for-relationship
public function run()
{
factory(App\Teacher::class, 2)->create()->each(function ($teacher) {
$teacher->students()->saveMany(factory(App\Student::class, 25)->make());
});
}
View a-teacher-student-relationship
public function students()
{
return $this->hasMany(Student::class, 'student_id');
}
@vineeth030
vineeth030 / model-factories-for-relationship-seeding
Created Nov 4, 2017
Model factories for relationship seeding
View model-factories-for-relationship-seeding
$factory->define(App\Student::class, function (Faker\Generator $faker) {
return [
'name' => $faker->name,
'marks' => $faker->numberBetween(0,100),
];
});
$factory->define(App\Teacher::class, function (Faker\Generator $faker) {
return [
'name' => $faker->name,
View Magento_2_api_docs.txt
Root URL [App URL] : http://phpstack-87385-243760.cloudwaysapps.com/index.php/rest/V1
Step 1 : [Get token & authenticate]
URL [ POST ]: Root URL + /integration/admin/token
Credentials :
Username : sculpapiuser1
Password : sculpapi1
Step 2 : [Get categories with token id]
View Laravel new project prep
Too long error
Add [ Schema::defaultStringLength(191); ] in AppServiceProvider.php
Bootstrap links
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
Vuejs link
<script src="https://unpkg.com/vue"></script>
View zen_snippet.php
// *Check to see if someone has clicked on a word out of the description text on the video page.*
// *If they have then do a search for that term.*
if(isset($_GET["term"]))
{
$termid = $_GET["term"];
if(is_numeric($termid))
{
zpConnectDB('zanesitecontent');
$sql = "SELECT g.id, g.term, t.name as topic, g.description FROM glossary AS g
@vineeth030
vineeth030 / pagination.php
Created Apr 28, 2016
Pagination with PHP & MYSQL
View pagination.php
<?php
$num_rec_per_page=10;
mysql_connect('localhost','root','');
mysql_select_db('apex1');
if (isset($_GET["page"])) { $page = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * $num_rec_per_page;
$sql = "SELECT * FROM student LIMIT $start_from, $num_rec_per_page";
$rs_result = mysql_query ($sql); //run the query
?>
<table>
You can’t perform that action at this time.