Latest Added Tutorials
Laravel Eloquent Column Editing with Yajra Datatables
class PrivatePackageController extends AppBaseController
{
public function index(){
try {
$model=PrivatePackage::query();
$result=DataTables::eloquent($model)
->setTotalRecords(100)
->editColumn('price', function(PrivatePackage $privatePackage) {
return MoneyUtil::twoDecimalNumber($privatePackage->price/100);
})
->toArray()['data'];
return $this->sendResponse($result,''...Continue Reading
Base Model for Laravel Mssql Datetime Configuration
use Illuminate\Database\Eloquent\Model;
abstract class BaseModel extends Model
{
protected $dateFormat = 'Y-m-d H:i:s.u';
public function getDateFormat()
{
return 'Y-m-d H:i:s.u';
}
public function fromDateTime($value)
{
return substr(parent::fromDateTime($value), 0, -3);
}
}...Continue Reading
config/auth.php file
'guards' => [
'crm_account' => [
'provider' => 'crm_accounts',
'driver' => 'passport',
'hash' => true,
],
],
'providers' => [
'crm_accounts' => [
'driver' => 'eloquent',
'model' => App\Models\CrmAccount::class,
'table' => 'crm_accounts',
],
],
CrmAccount Model:
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;
class CrmAccount extends Authenticatable
{
use HasApiTokens;
public $fillable = [
'id',
'name',
]...Continue Reading
25-02-2020
We can use following codes for multiple select in Laravel:
Blade Template:
<div class="form-group col-sm-6">
{!! Form::label('project_contents', 'Project Contents:') !!}
<i>(You can choose multiple items)</i>
@if(!isset($project))
{{Form::select('project_contents',$project_contents,null,
array('data-placeholder'=>'Seçiniz','class' => 'form-control select','multiple'=>'multiple',
'name'=>'project_contents[]','required'=>''))}}
@endif
@if(isset($project))
<select multiple="multiple" name="project_conten...Continue Reading
Laravel redirect all HTTP request to HTTPS request via .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /public/$1 [QSA,L]
</IfModule>...Continue Reading
11-12-2019
In laravel, we can enforce all routes to https by using following steps:
Open AppServiceProvider class and edit as follows:
namespace App\Providers;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
if(config('app.env') === 'prod'||config('app.env') === 'production') {
URL::forceScheme('https');
}
}
/**
* Register...Continue Reading
02-11-2019
$pdf = PDF::loadView('projects.pdf', ['project' => $project]);
$options = new Options();
$options->set('isPhpEnabled', 'true');
$dompdf = new Dompdf($options);
$dompdf->setOptions($options);
$dompdf->loadHtml('<html>....');
$dompdf->setPaper('A4', '');
$dompdf->render();
// Instantiate canvas instance
$canvas = $dompdf->getCanvas();
$w = $canvas->get_width();
$h = $canvas->get_height();
$pageNumberWidth = $w / 2;
$pageNumberHeight = $h - 50;
$GLOBALS["logo1"]=public_path('images/logo/icon.png');
$GLOBALS["logo2"]=public_path('images/logo/kultur_lo...Continue Reading
macOS Mojave Setup: Homebrew + Apache + PHP + MariaDB
Dropzone HTML Implementation
<link href="<?php echo base_url() ?>assets/css/dropzone.css" rel="stylesheet">
<div class="card">
<div class="row">
<div class="col-sm-12">
<div class="col-md-12 col-sm-12">
<form action="<?= base_url('admin/do_send_gallery'); ?>"
class="dropzone"
id="my-awesome-dropzone">
</form>
</div>
</div>
</div>
</div>
</div>
<script src="<?php echo base_url() ?>a...Continue Reading
21-01-2019
We can easly integrate file upload process in Laravel as follows:
1. Add following codes to create.blade.php file:
<div class="box box-primary">
<div class="box-body">
<div class="row">
{!! Form::open(['route' => 'applications.store','files'=>true]) !!}
<div class="form-group col-sm-6">
{!! Form::label('image', 'Image:') !!}
@if(isset($application->image))
<img src="{{asset("$application-/>image")}}" width="125" height="125"/>
<input...Continue Reading
21-01-2019
<div class="form-group col-sm-6">
{{Form::hidden('is_active',0)}}
{!! Form::label('is_active', 'Aktif:') !!}
{!! Form::checkbox('is_active') !!}
</div>...Continue Reading
17-02-2018
We can
Category Table
CREATE TABLE category
(
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50) NULL,
url VARCHAR(50) NULL,
parent INT NULL,
created_at TIMESTAMP NULL,
updated_at TIMESTAMP NULL,
deleted_at TIMESTAMP NULL,
resim VARCHAR(255) NULL,
kisaltma VARCHAR(255) NOT NULL,
CONSTRAINT category_category_parent_fk
FOREIGN KEY (parent) REFERENCES category (id)
ON DELETE SET NULL
)
ENGINE = InnoDB
COLLATE = utf8_unicode_ci;
CREATE INDEX category_category_parent_fk...Continue Reading
10-02-2018
public function html()
{
return $this->builder()
->columns($this->getColumns())
->minifiedAjax()
->addAction(['width' => '80px'])
->parameters([
'dom' => 'Blfrtip',
'order' => [[0, 'desc']],
"lengthMenu" => [10, 25, 50, 500],
"pageLength"=> "10",
'buttons' => [
'create',
'export',
'print',
'reset',
'reload',...Continue Reading
01-02-2018
To send onesignal notification in Php, we can use following codes:
function sendMessage($title, $message, $userId, array $extraParams, bool $isTest = false)
{
$app_id = "b21eaaf8-7da9-44e4-aa39-930e2503a109";
$rest_api_key = "NWEwMjU1YmItYzVmNy00YjBhLTlhNjEtNmZlMmUzOWU0Y2Ey";
$heading = array(
"en" => $title
);
$content = array(
"en" => $message
);
$fields = array(
'app_id' => $app_id,
'data' => $extraParams,
'contents' => $content,
'headings' => $heading
);
$fields['large_icon'] = 'http...Continue Reading
Php Steps
1. Install Socialite: composer require laravel/socialite
2. Add following codes in config/services.php
'google' => [
'client_id' => env('GOOGLE_CLIENT_ID'), // Your Google Client ID
'client_secret' => env('GOOGLE_CLIENT_SECRET'), // Your Google Client Secret
'redirect' => 'http://www.codesenior.com',
],
And add GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET variables in .env file:
GOOGLE_CLIENT_ID=692373818685-1s057a8mja62g3i7cmj88v2spt3d8b8e.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=c-4CsKAagTYHVyPKbGVcbAsr...Continue Reading