The error starts from here;
==> Installing [email protected] dependency: freetype
==> ./configure –prefix=/usr/local/Cellar/freetype/2.13.0_1 –enable-freetype-config –without-harfbuzz
==> make
I would be glad if anyone can help me. Thank you
Blancer.com Tutorials and projects
Freelance Projects, Design and Programming Tutorials
Category Added in a WPeMatico Campaign
The error starts from here;
==> Installing [email protected] dependency: freetype
==> ./configure –prefix=/usr/local/Cellar/freetype/2.13.0_1 –enable-freetype-config –without-harfbuzz
==> make
I would be glad if anyone can help me. Thank you
According to the official livewire docs we can bind data to the eloquent model’s properties directly like the following:
use AppPost;
class PostForm extends Component
{
public Post $post;
protected $rules = [
'post.title' => 'required|string|min:6',
'post.content' => 'required|string|max:500',
];
public function save()
{
$this->validate();
$this->post->save();
}
}
<form wire:submit.prevent="save">
<input type="text" wire:model="post.title">
<textarea wire:model="post.content"></textarea>
<button type="submit">Save</button>
</form>
But how can I upload an image and bind it to the model directly using the same approach?
I’m making use of the UserObserver to make sure everytime a user gets some experience points a new UserLevel is given to the user (in case of newly gained experience points are sufficient to level up / level down).
UserObserver:
public function updating(User $user){
//check if EXP amount was updated
if($user->isDirty('exp')){
//increased
if($user->experience_points > $user->getOriginal('experience_points')){
$nextLevel = $user->currentLevel->nextLevel();
while(!is_null($nextLevel) && $user->experience_points >= $nextLevel->experience_required) {
Log::info("current level: " . $user->current_level);
$user->current_level = $nextLevel->id;
Log::info("after edit level: " . $user->current_level);
$nextLevel = UserLevel::whereId($nextLevel->id + 1)->first();
}
}
//decreased
elseif($user->experience_points < $user->getOriginal('experience_points')){
$previousLevel = $user->currentLevel->previousLevel();
while(!is_null($previousLevel) && $user->experience_points <= $previousLevel->experience_required) {
Log::info("current level: " . $user->current_level);
$user->current_level = $previousLevel->id;
Log::info("after edit level: " . $user->current_level);
$previousLevel = UserLevel::whereId($previousLevel->id - 1)->first();
}
}
}
}
I’m able to follow the output of the observer:
[2023-03-11 18:53:36] local.INFO: current level: 1
[2023-03-11 18:53:36] local.INFO: after edit level: 2
[2023-03-11 18:53:36] local.INFO: current level: 2
[2023-03-11 18:53:36] local.INFO: after edit level: 3
[2023-03-11 18:53:36] local.INFO: current level: 3
[2023-03-11 18:53:36] local.INFO: after edit level: 4
[2023-03-11 18:53:36] local.INFO: current level: 4
[2023-03-11 18:53:36] local.INFO: after edit level: 5
Somehow the current_level field inside the database is not updated (still set to 1) after observer run is finished.
Any ideas to make the code more readable are welcome.
im trying to export data to pdf in laravel, i use dompdf
here’s my controller
use PDF;
public function pdf()
{
$spp = SPP::all();
$pdf = PDF::loadView('pdf.spp_pdf', ['spp' => $spp]);
return $pdf->download('laporanSPP.pdf');
}
my web.php
Route::get('/sppPDF', [SPPController::class, 'pdf'])->name('sppPDF');
my view
<ul class="responsive-table">
<li class="table-header">
<div class="col col-1">Tahun Masuk</div>
<div class="col col-2">Nominal Per Bulan</div>
<div class="col col-3">Nominal Total</div>
</li>
@foreach ($spp as $item)
<li class="table-row">
<div class="col col-1" data-label="Tahun Masuk">{{ $item->tahun }}</div>
<div class="col col-2" data-label="Nominal Per Bulan">{{ $item->per_bulan }}</div>
<div class="col col-3" data-label="Nominal Total">{{ $item->nominal }}</div>
</li>
@endforeach
</ul>
does anyone know how to solve it?
Okay this has been driving me crazy for the last few hours! So simple but it just doesn’t work and I really don’t see what’s going wrong here.
A simple sql query doesn’t work when using a variable, while with identical plain text it does.
To give a clear example, I have the code below with the output of all possible things that can go wrong.
<?php
$sRecipient = $data[0];
$sTitle = $titel;
$sBody = $bericht;
$sSender = $_SESSION['username'];
$aAttachments = null;
$iType = 0;
echo "Output $sRecipient: ".$sRecipient."";
$pdo = new PDO(DB_CONFIG_DSN, DB_CONFIG_USER, DB_CONFIG_PW);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$pdo->exec('SET NAMES "utf8"');
// NOT WORKING ???????????
$sql_user_details_var = "SELECT gebruikersnaam, internnummer FROM `leerlingen` WHERE `gebruikersnaam`='".$sRecipient."'";
$user_details_result = $pdo->query($sql_user_details_var);
$user_details_result = $pdo->query($sql_user_details_var)->fetch(PDO::FETCH_ASSOC);
// WORKING!
$sql_user_details_text = "SELECT gebruikersnaam, internnummer FROM `leerlingen` WHERE `gebruikersnaam`='[email protected]'";
$user_details_result = $pdo->query($sql_user_details_text);
$user_details_result = $pdo->query($sql_user_details_text)->fetch(PDO::FETCH_ASSOC);
echo "<br /><br />SQL with text: ".$sql_user_details_var."<br />";
echo "<br />SQL with var: ".$sql_user_details_text."<br /><br />";
// FOUND THE ROW!
$result_text = $pdo->query('select count(*) from `leerlingen` WHERE `gebruikersnaam`="[email protected]"')->fetchColumn();
// NOTHING FOUND ???????????
$result_var = $pdo->query('select count(*) from `leerlingen` WHERE `gebruikersnaam`="'.$sRecipient.'"')->fetchColumn();
echo "Result text: ".$result_text."<br />";
echo "Result var: ".$result_var."<br />";
?>
This is the output:
Output $sRecipient: [email protected]
SQL with text: SELECT gebruikersnaam, internnummer FROM `leerlingen` WHERE `gebruikersnaam`='[email protected]'
SQL with var: SELECT gebruikersnaam, internnummer FROM `leerlingen` WHERE `gebruikersnaam`='[email protected]'
Result text: 1
Result var: 0
Does anyone have any idea what I’m overlooking?
Tried everything, although you can’t go wrong with this, can you?
How to do an Indoor Map with Paths using Leaflet and TileLayer Tiles as my customized map?
I have a Node.js project that uses JWT for matching user’s token as authentication model. There are some APIs inside that project.
Now, I’m adding a new project with PHP that’s going to have some other APIs inside. I need to have the same JWT matching mechanism for this project too.
I mean, I want a token be valid both for the Node and PHP projects. Is it possible? If yes, is there any doc to help me how to do that?
I am having trouble configuring the permissions of a user with the ‘ROLE_USER’ role so that they can only edit, view, or delete their own articles with EasyAdmin 3. I have tried using the ‘setEntityPermission’ method, but it returns all articles, even those not created by the user. I have also tried to use the ‘setEntityPermissions’ method, but I receive the error ‘Undefined method’.
Here is my code:
<?php
namespace AppControllerAdmin;
use AppEntityUsers;
use AppEntityArticle;
use SymfonyBundleSecurityBundleSecurity;
use EasyCorpBundleEasyAdminBundleConfigCrud;
use EasyCorpBundleEasyAdminBundleConfigFilters;
use EasyCorpBundleEasyAdminBundleFieldSlugField;
use EasyCorpBundleEasyAdminBundleFieldTextField;
use EasyCorpBundleEasyAdminBundleFieldDateTimeField;
use EasyCorpBundleEasyAdminBundleFieldTextareaField;
use EasyCorpBundleEasyAdminBundleFilterEntityFilter;
use EasyCorpBundleEasyAdminBundleFieldTextEditorField;
use EasyCorpBundleEasyAdminBundleControllerAbstractCrudController;
use DoctrineORMEntityManagerInterface;
class ArticleCrudController extends AbstractCrudController
{
private $security;
private $entityManager;
public function __construct(Security $security, EntityManagerInterface $entityManager)
{
$this->security = $security;
$this->entityManager = $entityManager;
}
public static function getEntityFqcn(): string
{
return Article::class;
}
public function configureFields(string $pageName): iterable
{
// Define the fields to be displayed in the form for creating/editing an article
yield TextField::new('title');
yield SlugField::new('slug')
->setTargetFieldName('title');
yield TextEditorField::new('content');
yield TextareaField::new('featuredText', 'Texte mis en avant');
yield DateTimeField::new('createdAt')->hideOnForm();
yield DateTimeField::new('updatedAt')->hideOnForm();
// yield TextEditorField::new('author')->hideOnForm();
}
public function configureFilters(Filters $filters): Filters
{
// Define the filters for the article list page
$filters->add(EntityFilter::new('author'));
return $filters;
}
private function getArticlesByUser(Users $user): array
{
$user = $this->security->getUser();
if (!$user) {
return [];
}
$repository = $this->entityManager->getRepository(Article::class);
return $repository->findBy(['author' => $user]);
}
public function configureCrud(Crud $crud): Crud
{
$user = $this->security->getUser();
// If the user is an admin, display all the articles
if ($this->isGranted('ROLE_ADMIN')) {
return $crud;
}
// If the user is not an admin, display only the articles authored by the user
$articles = $this->getArticlesByUser($user);
// dd($articles); // With this dd(), I successfully retrieve the articles linked to the logged-in user.
return $crud
->setEntityPermission('ROLE_USER', 'EDIT', function (Article $article) use ($user, $articles) {
return $this->isGranted('ROLE_USER') && $article->getAuthor() === $user && in_array($article->getId(), $articles);
})
->setEntityPermission('ROLE_USER', 'VIEW', function (Article $article) use ($user, $articles) {
return $this->isGranted('ROLE_USER') && $article->getAuthor() === $user && in_array($article->getId(), $articles);
})
->setEntityPermission('ROLE_USER', 'DELETE', function (Article $article) use ($user, $articles) {
return $this->isGranted('ROLE_USER') && $article->getAuthor() === $user && in_array($article->getId(), $articles);
});
}
}
Thank you for your help.
I have a question. I wrote a query to the following code:
<ul>
<?php
$current_category = get_queried_object_id();
$query = new WP_Query( array(
'post_type' => 'table_partner', // name of post type.
'tax_query' => array(
array(
'taxonomy' => 'table_partner_tax', // taxonomy name
'field' => 'term_id', // term_id, slug or name
'terms' => $current_category, // term id, term slug or term name
'order' => 'ASC',
'orderby' => 'title'
)
)
) );
while ( $query->have_posts() ) : $query->the_post();
?>
<li><a href="<?php the_permalink();?>"><?php the_title();?></a> </li>
<?php
endwhile;
wp_reset_query();
?>
</ul>
But it does not sort by name
I wrote a
var_dump($query->request)
to see what orderby is telling me
ORDER BY wp_posts.post_date DESC LIMIT 0, 12
What should I do now to prioritize that sort with the title?
I from the code snippet
function remove_query_order($order) {
remove_filter('posts_orderby','remove_query_order',PHP_INT_MAX);
return '';
}
add_filter('posts_orderby','remove_query_order',PHP_INT_MAX);
I used it but it didn’t work
I have a string like this:
$str = "Hello आप कैसे हैं?";
I want to check whether the string contains Hindi or english language characters
I tried out this code:
if (preg_match('/[^A-Za-z]/', $str)){
//string contains hindi or english characters only
}
else{
//string contains some other foreign language characters
}
But this checks only for english characters, how do I check for hindi characters as well?
I made the following PHP function:
function root_include($path) {
include $_SERVER['DOCUMENT_ROOT'] . $path;
}
and then I added
root_include('/elements/text.php');
but it doesn’t work.
I was trying to include from the domain root, not the server root, and I am kind of a PHP noob so please educate me on what I did wrong.
EDIT: So apparently it does work, but I just can’t get any variables from the included file.
I can get variables from /elements/text.php with
include $_SERVER['DOCUMENT_ROOT'] . '/elements/text.php';
but not when I use the function for some reason, even though it’s supposed to be the same
I want to show a countdown on the products that will go on sale soon.
I have seen Premium Plugins, is there a free Plugin with which I can do this?
I have searched and tried Plugins but none do what I need.
Some Premium plugins can add countdowns to set offers on the price of the products, but I need to show the product in the store, and it cannot be purchased until the countdown ends.
It is necessary to add a Budge with the countdown in the products that we select, and prevent the purchase of that product until the countdown ends, and enable the purchase when the countdown time ends, it can be manually or automatically
Is there a Free Plugin to do this ?
Can it be done by code?
Thank you
In ListingFactory.php I have something like this
return [
"reviews" => json_encode([
'user' => fake()->name(),
'body' => fake()->paragraph(),
]),
]
Additionally, in the DatabaseSeeder.php I have this at the moment
AppModelsListing::factory(10)->create();
Any assistance is greatly appreciated
The current problem is that it will always generate one instance of review. What I want is a random number of reviews in a range.
For example, right now the table column of Review will always be [{}], I want something like [{}, {}, {}] or [].
I have wrote a script to copy client data over from our old system to the new system and it’s giving me the above error message.
I know the script is not very secure but it’s located on the internal network and is not open to the internet via firewall rules. I am monitoring use of the script very closely (When I get it working lol)
Full error message
Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘from cic_remus.contacts where (id=’127′)’ at line 1 in sender.php:16 Stack trace: #0 sender.php(16): mysqli_query() #1 {main} thrown in sender.php on line 16
I have gone through the code and everything appears to be correct and can’t seem to see what the problem is.
Both tables are the same and using the same version of PHP 8.2 and are located on the same server.
I know that I can just export and import but we are manually reviewing what information goes over and this is the easiest way for us to do it.
Code;
<?php
$databaseHost = 'localhost';
$databaseName = '';
$databaseUsername = '';
$databasePassword = '';
$mysqli = mysqli_connect($databaseHost, $databaseUsername, $databasePassword, $databaseName);
$id = $_GET['id'];
$sql="select from cic_remus.contacts where (id='$id');";
$res=mysqli_query($mysqli,$sql);
if (mysqli_num_rows($res) > 0) {
// output data of each row
$row = mysqli_fetch_assoc($res);
if($id==$row['id'])
{
echo "Already copied";
}
} else{
$query=mysqli_query($mysqli,"INSERT INTO cic_kenobi.contacts (status, image, datemovedin, learner_id, title, name, last_name, sex, dob, house_number, address_line_one, address_line_two, city_town, country, postcode, postcode_enrolment, phone, mobile_number, email_address, ethnic_origin, ethnicitys, health_problem, health_disability_problem_if_yes, lldd, education_health_care_plan, health_problem_start_date, education_entry, emergency_contact_details, employment_paid_status, employment_date, unemployed_month, education_training_prior, education_claiming, claiming_if_yes, household_situation, mentor, intext)
SELECT status, image, datemovedin, learner_id, title, name, last_name, sex, dob, house_number, address_line_one, address_line_two, city_town, country, postcode, postcode_enrolment, phone, mobile_number, email_address, ethnic_origin, ethnicitys, health_problem, health_disability_problem_if_yes, lldd, education_health_care_plan, health_problem_start_date, education_entry, emergency_contact_details, employment_paid_status, employment_date, unemployed_month, education_training_prior, education_claiming, claiming_if_yes, household_situation, mentor, intext
FROM cic_remus.contacts WHERE id =$id");
echo "Successfully copied";
}
?>
I want to get the due date and payment amount plus payment frequency of each shareholder in laravel.
assume subscription_date = 23/09/2023 subscribed_share = 5 one share value =1000 paidup_share = 1 unpaidup_share = subscribed_share – paidup_share payment = by monthly (31) based on this operation how to get expected payment and due date of this share collection. Any one please gives me idea I’m New for Laravel. kindly
This Is My Controller Named SharesubscribeController
<?php namespace AppHttpControllersAdmin;
use AppHttpControllersController;
use AppModelsAdminSharesubscribe;
use AppModelsAdminSharecollaction;
use AppModelsAdminCompany;
use IlluminateHttpRequest;
use IlluminateSupportStr;
use IlluminateValidationRule;
use CarbonCarbon;
use DB;
class SharesubscribeController extends Controller {
public function __construct() {
$this->middleware('admin');
}
public function index() {
//$sharesubscribe = Sharesubscribe::all();
//return view('admin.company.sharesubscribe.index', compact('sharesubscribe'));
$companye =DB: :table('companies')->get();
$client=DB: :table('clients')->get();
$sharesubscribe =Sharesubscribe: :all();
return view('admin.company.sharesubscribe.index', compact('sharesubscribe', 'companye', 'client'));
}
public function detail($id) {
$company =DB: :table('companies')->where('id', 1)->first();
// $subscribe_detail = DB::table('clients')->where('id', 1)->first();
$subscribe_detail =DB: :table('clients')->where('id', $id)->first();
$subscribe_list =DB: :table('sharesubscribes')->where('shareholder', $id)->get();
return view('admin.company.sharesubscribe.detail', compact('subscribe_detail', 'subscribe_list', 'company'));
}
public function create() {
$company=DB: :table('companies')->get();
$client=DB: :table('clients')->get();
return view('admin.company.sharesubscribe.create', compact('client', 'company'));
}
public function store(Request $request) {
$sharesubscribe =new Sharesubscribe();
$data =$request->only($sharesubscribe->getFillable());
$request->validate([ 'company_id '=> '',
'client_type'=> '',
'partial_payable'=> '',
'subscribed_share'=> 'required',
'price_per_share'=> '',
'subscribed_date'=> 'required',
'payment_date'=> '',
'payment_amount'=> '',
'total_unpaid_share'=> '',
'total_paidup_share'=> '',
'paidup_share'=> '',
'term'=> '',
'payment_frequancy'=> '',
'maturity_date'=> '',
'refrence'=> '',
'description'=> '',
'total_paidup_share'=> '',
'total_unpaid_share'=> '',
'created_by'
]);
$statement =DB: :select("SHOW TABLE STATUS LIKE 'sharesubscribe'");
$sharesubscribe =new Sharesubscribe();
$data =$request->only($sharesubscribe->getFillable());
$total_paidup_share =$request->subscribed_share - $request->paidup_share;
$subscribed_date =$request->input('subscribed_date');
$payment_date =$request->input('payment_date');
$paidup_share =$request->input('paidup_share');
$payment_amount =$request->input('payment_amount');
$shareholder =$request->input('shareholder');
$subscribed_share =$request->input('subscribed_share');
$term =12;
$maturity_date =$request->input('maturity_date');
$payment_frequancy =$request->input('payment_frequancy');
$date_approval =$request->input('subscribed_date');
$company_detail =DB: :table('companies')->where('id', $request->company_id)->pluck('authorized_share')->first();
if(empty($data['subscribed_share'])) {
unset($data['subscribed_share']);
$data['subscribed_share']=Str: :slug($request->id);
}
if($subscribed_share > $company_detail) {
return redirect()->back()->with ('error', 'Sorry! There are only ' .$company_detail.' Authorized share(s) in the company! First Please Authorized More Share');
}
if ($payment_date < $subscribed_date) {
return redirect()->back()->with ('error', 'Sorry! Your Subscribed Date is ' .$subscribed_date.' Payment Date Not Less than Subscribed Date ');
}
if ($paidup_share > $subscribed_share) {
return redirect()->back()->with ('error', 'Sorry! Your Subscribed Share is ' .$subscribed_share.' Paidup share Not Greater than Subscribed Share ');
}
$company_detail =DB::table('companies')->where('id', $request->company_id)->pluck('authorized_share', 'capital')->first();
$new_authorized_share =(int)$company_detail - (int)$request->subscribed_share;
// $new_capital = (int)$new_authorized_share * (int)$request->price_per_share;
Company::whereId($request->company_id)->update(['authorized_share'=> $new_authorized_share]);
// Company::whereId($request->company_id)->update(['capital' => $new_capital]);
$date_approval =Carbon::createFromTimestamp(strtotime($sharesubscribe->subscribed_date));
$new_term =$term * $num_days;
$days =(intdiv($date_approval->diff(Carbon::now())->days, $term) + 1) * $term $data['maturity_date']=$date_approval->addDays($days)->format('M d Y');
DB::raw('SUM(price) as total_sales') //$data['partial_payable'] = ('Individual');
$data['serial_no']=mt_rand(1000000000, 9999999999);
$sharesubscribe->fill($data)->save();
return redirect()->route('admin.company.sharesubscribe.index')->with ('success', 'Share Subscription is added successfully!');
}
}
?>
This is my Model named Sharesubscribe
<?php namespace AppModelsAdmin;
use IlluminateDatabaseEloquentModel;
class Sharecollaction extends Model {
protected $fillable =[ 'company_id',
'shareholder_id',
'subscribed_share',
'share_subscription_id',
'price_per_share'=>1000,
'subscribed_date',
'paidup_share',
'payment_date',
'payment_amount',
'partial_payable',
'term',
'payment_frequancy',
'maturity_date',
'total_share',
'serial_no',
'transaction_id',
'refrence',
'description',
'total_paidup_share',
'total_unpaid_share',
'created_by'
];
public function Company() {
return $this->hasOne('AppModelsAdminCompany', 'id', 'company_id');
}
public function Client() {
return $this->hasOne('AppModelsAdminClient', 'id', 'shareholder_id');
}
public function Sharesubscribe() {
return $this->hasOne('AppModelsAdminSharesubscribe', 'id', 'share_subscription_id');
}
}
?>
This is My Blade php Named Index
@extends('admin.admin_layouts') @section('admin_content') <h1 class="h3 mb-3 text-gray-800">Authorized Share</h1>
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 mt-2 font-weight-bold text-primary">View Authorized Share</h6>
<div class="float-right d-inline"><a href="{{ route('admin.company.authorizedmore.create') }}" class="btn btn-primary btn-sm"><i class="fa fa-plus"></i>Add New</a></div>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>SL</th>
<th>authorized Share</th>
<th>Per Value</th>
<th>Capital</th>
<th>Action</th>
</tr>
</thead>
<tbody>@foreach($authorizedmore as $row) <tr>
<td> {
{
$loop->iteration
}
}
</td>
<td> {
{
$row->authorized_amount
}
}
</td>
<td> {
{
$row->currency
}
}
{
{
$row->per_value
}
}
</td>
<td> {
{
$row->currency
}
}
{
{
number_format($row->capital, 3)
}
}
</td>
<td>
<div class="filter-dropdown text-right"><button type="button" class="btn btn-info btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Action</button>
<ul class="dropdown-menu"><a href="{{ URL::to('admin/company/authorizedmore/edit/'.$row->id) }}" class="btn btn-warning btn-sm btn-block"><i class="fas fa-edit"></i>Edit</a>
<li>
<hr class="dropdown-divider">
</li><a href="{{ URL::to('admin/company/authorizedmore/delete/'.$row->id) }}" class="btn btn-danger btn-sm btn-block" onClick="return confirm('Are you sure?');"><i class="fas fa-trash-alt"></i>Delete</a>
</td>
</tr>@endforeach </tbody>
</table>
</div>
</div>
@endsection
I really thank for taking your time!