eddy1992

Web developer intern at Experia Media

Hire Me

Experience

19,740

0 Best Reply Awards

  • Member Since 3 Years Ago
  • 73 Lessons Completed
  • 18 Favorites

25th May, 2018

eddy1992 left a reply on Secure The Apis From Hackers. • 3 weeks ago

Thank you so much @bobbybouwmann

eddy1992 started a new conversation Git Status Show Bad Object Head. • 3 weeks ago

I did git status and I am seeing this error. How can I solve this please assist if anyone has faced this issue before?

    git status
    fatal: bad object HEAD
    git fsck --full
    
    error: HEAD: invalid sha1 pointer 7b7cee7ecd496aa6a38d641a2a83480e4f68983d
    error: refs/heads/master: invalid sha1 pointer 7b7cee7ecd496aa6a38d641a2a83480e4f68983d
    
    error: HEAD: invalid reflog entry 7b7cee7ecd496aa6a38d641a2a83480e4f68983d
    error: refs/heads/master: invalid reflog entry 7b7cee7ecd496aa6a38d641a2a83480e4f68983d
    dangling blob f00de448e9864e419727a17ea2438514e1d10b1f
    dangling blob c221f6bb2006ff58d8207e41527a1f3cd0bdf485
    dangling blob e665c10c7fc97661dd3bd980b11ebeeab1649409
    dangling blob 716af2645775c1594629e84463947c413e8b60c0
    dangling commit dfaefd2f623dc3e2ecdfefe881f56cf4b3bc75c4
    dangling blob aabb3d2087f289f1d1c01f13fbf897fb2436d0a7
    dangling blob 3ad27c5164f7c03814cfdcce4a451be6926c4e5a
    dangling commit f5d9fd4d24a3509fc5a53ca426d10541c94f8b79
    dangling blob 4ef15c7ebb44c156dc01b881d8899a6f360464de

11th May, 2018

eddy1992 started a new conversation Secure The Apis From Hackers. • 1 month ago

Hi, guys I have some restful API's which are connected to two apps the ios and android. I have no security on them. I want to secure the API's now. The API's are build on Laravel 5.2. I want to know what options do I have? Please assist.

13th April, 2018

eddy1992 started a new conversation Sql Injection • 2 months ago

Hi, I have a project which is running an old version of PHP and MySQL. I am using queries like this

mysql_query("select * from user_favorites1 where users_id='$user_phone' AND products_id='$products_id' LIMIT 0,1");
$count=mysql_num_rows($ip_sql);

$sql_in = "insert into user_favorites1 (users_id,products_id,user_country_code,lastupdatetime,isAd) values ('$user_phone','$products_id','$user_country_code','$mss','$isAd')";
mysql_query($sql_in);
$result = array("status" => 0);
echo json_encode($result);

What will be the way to prevent SQL injection in the current code base rather than upgrading the whole code. Please assist.

7th March, 2018

eddy1992 started a new conversation Saving Json In A Column And Searching Back. • 3 months ago

Hi, I am using Laravel 5.2 and using Maria DB and I know I could create a column varchar and store JSON in it. Now I wanted to know if I could search them back also? Is that possible in Laravel 5.2. I found that in Laravel 5.3 and Mysql 5.7 we have JSON but I do not have that privilige. Please assist if there is a way.

10th February, 2018

eddy1992 started a new conversation WhereBetween Passing Value And Null • 4 months ago

I have an eloquent query and I am passing a value and null in it. So for example if I have an area column and I have two variables $to and $from.

example $from = 10 $to= ""

    $from = 10;
    $to = "";  
    Product::whereBetween('area', [$from, $to])->get();

my question is that is this okay , will this work ? If no then what shall I do if I want to search from 10 to infinity ?

please assist. Thank you.

6th February, 2018

eddy1992 left a reply on WhereBetween Passing Array • 4 months ago

@bobbybouwmann Okay thank you so much for your time and effort. :)

eddy1992 left a reply on WhereBetween Passing Array • 4 months ago

@bobbybouwmann Thank you so much for your response and answer, I am curious to know is there a way we could achieve this without the foreach ?

eddy1992 started a new conversation WhereBetween Passing Array • 4 months ago

Hi I have query where I want to pass an array to whereBetween query.

for example I have an array which looks like this

Array
(
    [product_id] => Array
        (
            [0] => 31337
            [1] => 31366
        )

    [lands] => Array
        (
            [0] => 12
            [1] => 23
        )

)

Now I want search those product_id which are between [0] => 31337 and [1] => 31366 and same goes to land I want to find the lands where Between [0] => 1 and [1] => 23

now say I have a variable $filters which has the this above array in it and I pass it like this to the query like below.

public function scopeDynamicInBetweenFilter($query, $filters)
    {
        if(!empty($filters)){
            return $query->whereBetween($filters);
        }
        return $query;
    }

It gives me an error

Type error: Too few arguments to function Illuminate\Database\Query\Builder::whereBetween(), 1 passed and at least 2 expected

it does like this at Builder->whereBetween(array('product_id' => array('31337', '31366'), 'lands' => array('12', '23')))

please tell me what could be done to achieve this. Please assist

23rd January, 2018

eddy1992 started a new conversation Schema Has Returning Empty • 4 months ago

Hi I am facing a weird issue where I added a new column named condition in table named products1. Now the issue is that I used to check if the column exist or not using

$filterId = "condition"
 Schema::hasColumn('products1', $filterId);

Now I added a new column named condition and its returning me false and I am 100% sure that the column exists.

Any idea why this would happen. Please assist. Thank you.

11th January, 2018

eddy1992 started a new conversation 'Illuminate\Database\QueryException SQLSTATE[42000]: • 5 months ago

Hi I am checking on new relic and I see some errors coming and it shows like this

Exception 'Illuminate\Database\QueryException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 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 'offset 0' at line 1 (SQL: select * from `products1` where `categories_category_id` = 198 and `subcat` = 231 and `categoryAdvertiseTypeId` = 0 and MATCH (product_name, productNameArabic, productNameEnglish, product_Description, productDescriptionArabic, productDescriptionEnglish) AGAINST ( تركيب خيم وعنن وبيوت الشعر IN NATURAL LANGUAGE MODE) and `startdate` > 1510401145890 and `active` = 0 order by `startdate` desc offset 0)' in /home/apimzad/public_html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:729

any idea what I might be doing wrong

my query

public function searchAdsInProducts1($data)
    {
        $searchString = $data->get('searchStr');
        $categoryId = $data->get('productId');//categories_category_id ie. car, property etc.
        $subCategoryIds = $data->get('subCategoryId');//subcat
        $subSubCategoryIds = $data->get('subsubCategoryId');//subsubCategoryId
        $productsLanguage = $data->get('productsLang');//lang
        $numberPerPage = $data->get('numberperpage');

        $manfactureYearFrom = $data->get('manfactureYearFrom');
        $manfactureYearTo = $data->get('manfactureYearTo');
        $kmFrom = $data->get('kmFrom');
        $kmTo = $data->get('kmTo');
        $priceFrom = $data->get('priceFrom');
        $priceTo = $data->get('priceTo');
        $regionId = $data->get('regionId');
        $furnishedTypeId = $data->get('furnishedTypeId');
        $numberOfRoomsFrom = $data->get('numberOfRoomsFrom');
        $numberOfRoomsTo = $data->get('numberOfRoomsTo');
        $cityId = $data->get('cityId');
        $categoryAdvertiseTypeId = $data->get('categoryAdvertiseTypeId');
        $orderBy = $this->decideOrderBy($data);
        $time = $this->decideTime($data);

        $page = $data->get('page', 1);

        // Items per page (maybe put this in a config file?)
        // $perPage = $data->get('numberperpage');
        $perPage = $data->get('numberperpage');
        // Calculate the offset based on the current page.
        $offset = ($page * $perPage) - $perPage;


        if(($data->get('page') == 1)){

            $sticky = Product::with(['category', 'getCity', 'getRegion', 'getVideo'])
                    ->categoriesCategoryId($categoryId)
                    // ->where('companies', 1)
                    ->where('sticky', 1)
                    // ->subSubCategory($subSubCategoryIds)
                    // ->subCat($subCategoryIds)
                    ->categoryAdvertiseTypeId($categoryAdvertiseTypeId)
                    // ->regionId($regionId)
                    // ->furnishedTypeId($furnishedTypeId)
                    // ->cityId($cityId)
                    // ->searchString($searchString)
                    // ->km($kmFrom, $kmTo)
                    // ->price($priceFrom, $priceTo)
                    // ->numberOfRooms($numberOfRoomsFrom, $numberOfRoomsTo)
                    // ->manufactureYear($manfactureYearFrom, $manfactureYearTo)
                    // ->language($productsLanguage)
                    // ->orderBy('product_id', 'desc')
                    // ->active()//
                    // ->inReview()//for new advertisement flow.
                    ->lastOneMonth($categoryId)
                    ->orderByRaw('RAND()')
                    ->take(30)
                    ->get();
        }

        if(($data->get('page') == 1) AND ($categoryId != 0)){
            if(!$sticky->isEmpty()){
                $countOfStarAds = $sticky->count();

                $perPage = $data->get('numberperpage') - $countOfStarAds;
            }
        }


        $ads = Product::with(['category', 'getCity', 'getRegion', 'getVideo'])
                ->categoriesCategoryId($categoryId)
                ->subSubCategory($subSubCategoryIds)
                ->subCat($subCategoryIds)
                ->categoryAdvertiseTypeId($categoryAdvertiseTypeId)
                ->regionId($regionId)
                ->furnishedTypeId($furnishedTypeId)
                ->cityId($cityId)
                ->searchString($searchString, $categoryId)
                ->km($kmFrom, $kmTo)
                ->price($priceFrom, $priceTo)
                ->numberOfRooms($numberOfRoomsFrom, $numberOfRoomsTo)
                ->manufactureYear($manfactureYearFrom, $manfactureYearTo)
                ->lastTwoMonths($categoryId)
                ->time($time)
                ->language($productsLanguage)
                ->orderBy($orderBy, 'desc')
                ->active()//
                // ->inReview()////for new advertisement flow.
                ->skip($offset)//remove if not working
                ->take($perPage)//remove if not working
                // ->paginate(50, ['*'], 'page', $page);
                ->get();

        if($data->get('isAdsSupported') == 'true'){
            $paidAds = $this->getPaidAds($data);
        }

        if(($data->get('page') == 1) AND ($categoryId != 0)) {
            // $data = $ads;
            $data = $sticky->merge($ads);
        }else{
            $data = $ads;
        }

        return ['ads' => $data, 'paidAds' => $paidAds];
    }

please tell me what I am doing

5th January, 2018

eddy1992 started a new conversation SSL Operation Failed • 5 months ago

Hi guys I have code to which is supposed to send ios push messages but it is giving me an error do not know why ?

my code

$streamContextCreate = stream_context_create();
            
            stream_context_set_option($streamContextCreate, 'ssl', 'local_cert', '/home/devmzad/public_html/public/ios/MzadDevCertificates.pem');
            
            $fp = stream_socket_client(
                'ssl://gateway.push.apple.com:2195', $err,
                $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $streamContextCreate);
            echo "<pre>";
            print_r($fp); //gives error here.
            die;

the error

stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:
error:14094438:SSL routines:SSL3_READ_BYTES:tlsv1 alert internal error

Guys would appreciate if someone could help me with please that why this is giving this weird error ?

22nd December, 2017

eddy1992 started a new conversation My Api Is Slow And Facing 504 Error Sometimes. • 5 months ago

Hi guys I have an api and that api purpose is it to fetch all the products. So this api is giving us some trouble as its slow on live and sometimes gets stuck and gives us 504 time out error. It has become complete nightmare why it happens and I am not able to figure that out, hopefully some one could just see and tell what might be the reason for the slowness.

so I have a controller GetCategoryDataApiController this has the method named getCategoryData this will get the post data and process further.


<?php

namespace App\Http\Controllers\API;

use Illuminate\Http\Request;

use DB;
use App\User;
use App\City;
use App\Product;
use App\Category;
use App\Http\Requests;
use App\Product_images1;
use App\Http\Controllers\Controller2;
use App\Http\Traits\ProductsOneTableLangTrait;
use App\Http\Traits\ProductOneImageUtilityTrait;
use App\Http\Traits\ProductOneUtilityTrait;
use App\Http\Traits\UtilitiesTrait;

class GetCategoryDataApiController extends Controller2
{   
    /**
     * This trait will handle all the 
     * data that will be filtered 
     * on the basis of language
     */
    use ProductsOneTableLangTrait, 
    ProductOneImageUtilityTrait, 
    ProductOneUtilityTrait,
    UtilitiesTrait;


    /**
     * the website url
     * @var string
     */
    protected $website;


    /**
     * device language the user pass
     * @var string
     */
    protected $deviceLanguage;


    /**
     * products Language the use pass
     * @var string
     */
    protected $prodLanguage;



    protected $lastupdatetime;


    protected $countOfRow;

    /**
     * get the category data  
     * @param  Request $request 
     * @return json we would get the ads from the products1 table.
     */
    public function getCategoryData(Request $request)
    {   
        
        $data = $request->json();
        $this->setLanguage($data);

        $adsFound = $this->searchAdsInProducts1($data); // this would get all the products.
        $ads = $this->createJsonFormatForGetCategoryData($adsFound['ads'], $this->deviceLanguage);
        return $this->mergePaidAdsWithNormalAds($ads, $adsFound['paidAds']);
    }   


    /**
     * set language so we could refer it 
     * in the code whenever needed
     * @param $data this is the request param
     */
    public function setLanguage($data)
    {   
        $this->website = config('app.url');
        $this->deviceLanguage = $data->get('userDeviceLanguage');
        $this->prodLanguage = $data->get('productsLang');
        $this->countOfRow = $data->get('countOfRow');
        $this->lastupdatetime = ($data->get('lastupdatetime')) 
        ?  $data->get('lastupdatetime')
        :  $this->lastUpdateTime();
    }

    
    public function createJsonFormatForGetCategoryData($data, $lang)
    {
        if(!$data->isEmpty()){

            $index = 0;
            foreach($data as $key => $item) {

                $categoryName = $this->getCategoryNameOnBasisOfLang($item->categories_category_id, $lang);
                $subCategoryName = $this->getCategoryNameOnBasisOfLang($item->subcat, $lang);
                $subsubCategoryName = $this->getCategoryNameOnBasisOfLang($item->subsubCategoryId, $lang);

                $cityName = $this->getCityNameDependLanguage($lang, $item);
                $advertiseName = Category::getAdvertiseType($item->categoryAdvertiseTypeId, $lang);
                $furnishedTypeName = $this->getFurnishedNameDependLanguage($lang, $item);
                // $properties = $this->addPropertiesArray($categoryName,$subCategoryName,$advertiseName,$item->manfactureYear,$furnishedTypeName,$lang,$item);
                $manfactureYearId = $this->getManufactureIdFromYear($item->manfactureYear);
                $properties = $this->addProperties($item,$advertiseName,$subsubCategoryName,$subCategoryName,$furnishedTypeName,$manfactureYearId,$lang);

                
                $mainImage = $this->getProductMainImage($item, $this->website);

                $products[] = [
                    'dateOfAdvertise'          => $item->startdate,
                    'isAd'                     => $item->isAd,
                    'isShowAddCommentAndLikes' => $item->isShowAddCommentAndLIkes,
                    'productId'               =>  "$item->product_id",
                    'categoryAdvertiseTypeId'  => $item->categoryAdvertiseTypeId,
                    'productName'              => $this->setProductNameUsingLang($item, $this->prodLanguage),
                    'productNameEnglish'       => $item->productNameEnglish,
                    'productNameArabic'        => $item->productNameArabic,
                    'productPrice'             => "$item->product_price",
                    'productDescription'       => $item->product_Description,
                    'productDescriptionEnglish'=> $item->productDescriptionEnglish,
                    'productDescriptionArabic' => $item->productDescriptionArabic,
                    'categoryId'               => "$item->categories_category_id",
                    'categoryName'             => $categoryName,
                    'subCategoryId'            => "$item->subcat",
                    'subCategoryName'          => $subCategoryName,
                    'subsubCategoryId'         => $item->subsubCategoryId,
                    'subsubCategoryName'       => $subsubCategoryName,
                    'categoryAdvertiseTypeName'=> $advertiseName,
                    'cityId'                   => $item->cityId,
                    'cityName'                 => $cityName,
                    'regionId'                 => $item->regionId,
                    'regionName'               => $this->getRegionNameDependLanguage($lang, $item),
                    'manfactureYear'           => $this->convertDateToTheLang($lang, $item->manfactureYear),
                    'km'                       => $item->km,
                    'furnishedTypeId'          => $item->furnishedTypeId,
                    'furnishedTypeName'        => $furnishedTypeName,
                    'numberOfRooms'            => $item->numberOfRooms,
                    'commentCount'             => "$item->comment",
                    'likeCount'                => $this->getUserLikes($data, $item),
                    'productAdvertiseUrl'      => $item->productAdvertiseUrl,
                    'isCompany'                => $item->companies,
                    'clickType'                => $item->clickType,
                    'productMainImage'         => $mainImage,
                    'userCountryCode'          => $item->countries_country_id,
                    'userNumber'               => "$item->users_user_id",
                    'userName'                 => User::findUserNameBasedOnNumber($item->users_user_id, $this->deviceLanguage),
                    'userEmail'                => User::findEmailBasedOnNumber($item->users_user_id),
                    'userPhoto'                => User::findUserPhotoBasedOnNumber($item->users_user_id),
                    'userSmallDescription'     => User::getUserInfo($item->users_user_id),
                    'userProfileLink'          => $this->profileLink($item, $this->website),
                    'productUrl'               => $this->productUrl($item, $this->website),
                    'productShareImage'        => $this->productShareImage($item, $this->website),
                    'advertiseTimeFormatted'   => $this->getAdvertiseTimeFormatted($item, $lang),
                    'numberOfViews'            => "$item->points",
                    'lang'                     => $item->lang,
                    'properties'               => $properties,
                    'productImages'            => $this->getProductImages($item, $this->website),
                    'productMainImageNewSize'  => $mainImage,
                    'productAttachments'       => $this->getProdAttachments($item, $this->website),
                    'isMainVideo'              => $this->setIsMainVideo($mainImage, $item),
                    'mainAttachment'           => $mainImage,
                    'manfactureYearId'         => $manfactureYearId,
                    'longitude'                => $item->longitude,
                    'latitude'                 => $item->latitude,
                    'location'                 => $item->location
                ];
            }
            $productInfo['lastupdatetime'] = "$this->lastupdatetime";
            $productInfo['products'] = $products;

            return $productInfo;
        }

        return [
            'lastupdatetime' => "$this->lastupdatetime",
            'products' => []
        ];
    }

    public function mergePaidAdsWithNormalAds($ads, $paidAds)
    {   
        $key = ($this->countOfRow * 4) - ((0 * ($this->countOfRow - 1)) + $this->countOfRow);
        $countOfAds = count($ads['products']);
        if($key < $countOfAds){
            $ads['products'][$key] = $paidAds;
            return $ads;
        }else{
            return $ads;
        }
    }
}



Now $adsFound = $this->searchAdsInProducts1($data); this would fetch the records from the table using eloquent. In this method we are just fetching using the query scope and merging two record sets.

/**
     * we would search the products 1 table
     * with all the request params posted
     * we would query only when the request 
     * params are passed.
     * @param  object $data This is the request param
     * @return eloquent collection
     */
    public function searchAdsInProducts1($data)
    {   
        $searchString = $data->get('searchStr');
        $categoryId = $data->get('productId');//categories_category_id ie. car, property etc.
        $subCategoryIds = $data->get('subCategoryId');//subcat
        $subSubCategoryIds = $data->get('subsubCategoryId');//subsubCategoryId
        $productsLanguage = $data->get('productsLang');//lang
        $numberPerPage = $data->get('numberperpage');

        $manfactureYearFrom = $data->get('manfactureYearFrom');
        $manfactureYearTo = $data->get('manfactureYearTo');
        $kmFrom = $data->get('kmFrom');
        $kmTo = $data->get('kmTo');
        $priceFrom = $data->get('priceFrom');
        $priceTo = $data->get('priceTo');
        $regionId = $data->get('regionId');
        $furnishedTypeId = $data->get('furnishedTypeId');
        $numberOfRoomsFrom = $data->get('numberOfRoomsFrom');
        $numberOfRoomsTo = $data->get('numberOfRoomsTo');
        $cityId = $data->get('cityId');
        $categoryAdvertiseTypeId = $data->get('categoryAdvertiseTypeId');
        $orderBy = $this->decideOrderBy($data);
        $time = $this->decideTime($data);

        $page = $data->get('page', 1);

        // Items per page (maybe put this in a config file?)
        $perPage = 50; 

        // Calculate the offset based on the current page.
        $offset = ($page * $perPage) - $perPage;

        if(($data->get('page') == 1)){

            $sticky = Product::categoriesCategoryId($categoryId)
                    // ->where('companies', 1)
                    ->where('sticky', 1)
                    // ->subSubCategory($subSubCategoryIds)
                    // ->subCat($subCategoryIds)
                    ->categoryAdvertiseTypeId($categoryAdvertiseTypeId)
                    
                    ->orderBy('product_id', 'desc')
                    ->take(50)
                    ->get();
        }
        
        $ads = Product::categoriesCategoryId($categoryId)
                ->subSubCategory($subSubCategoryIds)
                ->subCat($subCategoryIds)
                ->categoryAdvertiseTypeId($categoryAdvertiseTypeId)
                ->regionId($regionId)
                ->furnishedTypeId($furnishedTypeId)
                ->cityId($cityId)
                ->searchString($searchString, $categoryId)
                ->km($kmFrom, $kmTo)
                ->price($priceFrom, $priceTo)
                ->numberOfRooms($numberOfRoomsFrom, $numberOfRoomsTo)
                ->manufactureYear($manfactureYearFrom, $manfactureYearTo)
                // ->lastTwoMonths($categoryId)
                ->time($time)
                ->language($productsLanguage)
                ->orderBy($orderBy, 'desc')
                ->skip($offset)//remove if not working
                ->take($perPage)//remove if not working
                // ->paginate(50, ['*'], 'page', $page);
                ->get();

        if($data->get('isAdsSupported') == 'true'){
            $paidAds = $this->getPaidAds($data);
        }

        if(($data->get('page') == 1) AND ($categoryId != 0)) {
            // $data = $ads;
            $data = $sticky->merge($ads);
        }else{
            $data = $ads;
        }

        return ['ads' => $data, 'paidAds' => $paidAds];
    }

This all what is happening. I would appreciate your views in how I could improve this and then improve performance , or if you feel there is something suspicious then please let me know. Thank you. Please assist.

eddy1992 left a reply on Pagination For Api. • 5 months ago

Thank you so much @bobbybouwmann , I think the issue is somewhere else for the performance.

19th December, 2017

eddy1992 started a new conversation Search Columns Using % Like % • 6 months ago

Hi guys I have a question , If I had to search multiple columns using eloquent query scope how will I do it . The below elquent query giving me less results when searching. Is this correct to search a string in columns in a table. Please assist.

/**
     * query scope for search string
     * @param  $query
     * @param  String $searchString 
     * @return 
     */
    public function scopeSearchString($query, $searchString)
    {   
        if(!empty($searchString)){
            return $query->where('product_name', 'like', '%'.$searchString.'%')
                    ->orWhere('product_Description', 'like', '%'.$searchString.'%')
                    ->orWhere('users_user_id', 'like', '%'.$searchString.'%')
                    ->orWhere('productNameArabic', 'like', '%'.$searchString.'%')
                    ->orWhere('productNameEnglish', 'like', '%'.$searchString.'%')
                    ->orWhere('productDescriptionArabic', 'like', '%'.$searchString.'%')
                    ->orWhere('productDescriptionEnglish', 'like', '%'.$searchString.'%');
        }
        return $query;
    }

17th December, 2017

eddy1992 left a reply on Pagination For Api. • 6 months ago

Hi @bobbybouwmann wow thanks for that answer. It would be really helpful if you could provide me an example. I think the second options seems perfect for me. Thank you so much.

eddy1992 started a new conversation Pagination For Api. • 6 months ago

Hi guys I have two queries that would fetch records for me but I am using laravel paginator and I feel its making it slow, I am doing this query for api

/**
     * we would search the products 1 table
     * with all the request params posted
     * we would query only when the request 
     * params are passed.
     * @param  object $data This is the request param
     * @return eloquent collection
     */
    public function searchAdsInProducts1($data)
    {   
        $searchString = $data->get('searchStr');
        $categoryId = $data->get('productId');//categories_category_id ie. car, property etc.
        $subCategoryIds = $data->get('subCategoryId');//subcat
        $subSubCategoryIds = $data->get('subsubCategoryId');//subsubCategoryId
        $productsLanguage = $data->get('productsLang');//lang
        $page = $data->get('page');
        $numberPerPage = $data->get('numberperpage');

        $manfactureYearFrom = $data->get('manfactureYearFrom');
        $manfactureYearTo = $data->get('manfactureYearTo');
        $kmFrom = $data->get('kmFrom');
        $kmTo = $data->get('kmTo');
        $priceFrom = $data->get('priceFrom');
        $priceTo = $data->get('priceTo');
        $regionId = $data->get('regionId');
        $furnishedTypeId = $data->get('furnishedTypeId');
        $numberOfRoomsFrom = $data->get('numberOfRoomsFrom');
        $numberOfRoomsTo = $data->get('numberOfRoomsTo');
        $cityId = $data->get('cityId');
        $categoryAdvertiseTypeId = $data->get('categoryAdvertiseTypeId');
        $orderBy = $this->decideOrderBy($data);
        $time = $this->decideTime($data);

        if(($data->get('page') == 1) AND ($categoryId != 0)){

            $sticky = Product::categoriesCategoryId($categoryId)
                    ->where('companies', 1)
                    ->where('sticky', 1)
                    // ->subSubCategory($subSubCategoryIds)
                    // ->subCat($subCategoryIds)
                    ->categoryAdvertiseTypeId($categoryAdvertiseTypeId)
                    ->regionId($regionId)
                    ->furnishedTypeId($furnishedTypeId)
                    ->cityId($cityId)
                    // ->searchString($searchString)
                    ->km($kmFrom, $kmTo)
                    ->price($priceFrom, $priceTo)
                    ->numberOfRooms($numberOfRoomsFrom, $numberOfRoomsTo)
                    ->manufactureYear($manfactureYearFrom, $manfactureYearTo)
                    // ->language($productsLanguage)
                    ->orderBy('product_id', 'desc')
                    ->take(50)
                    ->get();
        }

        $ads = Product::categoriesCategoryId($categoryId)
                ->subSubCategory($subSubCategoryIds)
                ->subCat($subCategoryIds)
                ->categoryAdvertiseTypeId($categoryAdvertiseTypeId)
                ->regionId($regionId)
                ->furnishedTypeId($furnishedTypeId)
                ->cityId($cityId)
                ->searchString($searchString)
                ->km($kmFrom, $kmTo)
                ->price($priceFrom, $priceTo)
                ->numberOfRooms($numberOfRoomsFrom, $numberOfRoomsTo)
                ->manufactureYear($manfactureYearFrom, $manfactureYearTo)
                ->lastTwoMonths($categoryId)
                ->time($time)
                ->language($productsLanguage)
                ->orderBy($orderBy, 'desc')
                ->paginate(50, ['*'], 'page', $page);

        if($data->get('isAdsSupported') == 'true'){
            $paidAds = $this->getPaidAds($data);
        }

        if(($data->get('page') == 1) AND ($categoryId != 0)) {
            // $data = $ads;
            $data = $sticky->merge($ads);
        }else{
            $data = $ads;
        }

        return ['ads' => $data, 'paidAds' => $paidAds];
    }

When I see db log query it does SELECT count(*) as aggregate

Now I have million records and it would do count *, I feel this would make it slow, is there any other alternative to this for api ? Please suggest thank you.

16th December, 2017

eddy1992 left a reply on Search On The Last Two Months Records • 6 months ago

@Snapey If I do recent() in the first then it would first search only in the scope of last month, and if do in the last then it would do something else right ?

eddy1992 left a reply on Search On The Last Two Months Records • 6 months ago

@Snapey Thank you so much for your answer.

eddy1992 left a reply on Search On The Last Two Months Records • 6 months ago

@Snapey thanks for you reply , so doing a simple where would do the trick ? so it would search from all the records when done with where date = 2 months before from now ?

eddy1992 started a new conversation Search On The Last Two Months Records • 6 months ago

Hi I have a situation where I have millions of records in a table and I dont want to search the whole record set all times. Imagine I have a products table and I have 1 million products of last 5 years and to search something like finding product name I have to search the whole records, can I do something like search only the last two months records. So that the performance improves. If yes how will I do it using eloquent ?

please assist.

13th November, 2017

eddy1992 left a reply on Having Condition In A Laravel Eloquent Query. • 7 months ago

@tykus Thank you so much for your reply but I wanted to know whether I could user sortBy() to achieve this ?

eddy1992 started a new conversation Having Condition In A Laravel Eloquent Query. • 7 months ago

Hi I have an eloquent query and the table I am querying contains a column named active. So active could be 1 or 0. Now I am querying all the records from the table, that means I have all the records which may have active = 1 or active = 0. Now what I want to do is that I want to show or get the active = 1 records first then the those records which have active = 0.

//now Imagine we get all the records from this query so the $allRecords variable has 
//all the records which are active and not active.
$allRecords = Product::where('city', 'New York')->get();

//Now I want to sequence or reorder the collection where I want to show the active=1 first then active=0.

please assist.

25th October, 2017

eddy1992 started a new conversation Bind List Item Array Vue Data To Input Value In A Form • 7 months ago

Hi I have a form and I have a input field in which I have a vue event which allows to take some values and add it to a data a object in the vue js, but I am not able to bind this vue data property to the input value so I would get back when the form is submitted.

My input

<div class="col-md-4">
   <ul>
      <li v-for="item in filterListValueEnArray">
         @{{ item }}
         <button @click.prevent="removeFilterEn(filterListValueEn)">remove</button>
      </li>
   </ul>
   <input type="text" v-model="filterListValueEn" @keydown.enter.prevent="addFilterValEn(filterListValueEn)" name="array" v-bind:value="filterListValueEnArray" class="form-control">
</div>

vue js code

        new Vue({
            el: '#advFilter',

            data: {
                selectFilterType: '',
                
                filterListValueEn: '',
                filterListValueEnArray: [],
                filterListValueAr: '',
                filterListValueArArray: [],
            },

            methods: {
                addFilterValEn: function(filterListValueEn) {
                    this.filterListValueEnArray.push(filterListValueEn);
                    this.filterListValueEn = '';

                },
                addFilterValAr: function(filterListValueAr) {
                    this.filterListValueArArray.push(filterListValueAr);
                    this.filterListValueAr = '';    
                },
                removeFilterAr: function(filterListValueAr) {
                    this.filterListValueArArray.pop(filterListValueAr)
                },
                removeFilterEn: function(filterListValueEn) {
                    this.filterListValueEnArray.pop(filterListValueEn)
                }
            }
        });

I want to bind the filterListValueEnArray in the value of the text field but I dont get back anything when I do

$request->all();

Please assist

29th September, 2017

eddy1992 left a reply on Laravel Db::raw Query For The Query Scope. • 8 months ago

@36864 thank you for you response please check I have edited my question

eddy1992 started a new conversation Laravel Db::raw Query For The Query Scope. • 8 months ago

Hi I have a query scope in laravel and I have a column named km which is varchar. Now I want to write a raw query scope for it. The problem is it wont search for the varchar. So need to cast km to unsigned.

    public function scopeKm($query, $kmFrom, $kmTo)
    {   
        $kmFrom = (int)$kmFrom;
        $kmFrom = (int)$kmTo;

        if((count($kmFrom) > 0) && count($kmTo) > 0){ 

            return $query->whereBetween('km', [$kmFrom, $kmTo]);   
        }
        return $query;
    }

I want to write the db raw query for the above in which I cast the km column to unsigned in the raw query.

eddy1992 left a reply on WhereBetween() Eloquent Returning Wrong Results • 8 months ago

@ChristophHarms thank you for your reply. Even If I am trying to pass integer same issue.

eddy1992 left a reply on WhereBetween() Eloquent Returning Wrong Results • 8 months ago

@nadj Its varchar(10).

eddy1992 started a new conversation WhereBetween() Eloquent Returning Wrong Results • 8 months ago

Hi I have a eloquent query and I am using query scope. I have a km column in my table and I am passing kmFrom and KmTo values as post data. Now I am doing a eloquent whereBetween and its returning wrong results when I search for km.

For example if I pass kmFrom = 1000 and kmTo = 2000. Its giving me results which are not in between these two values.

Eloquent

Product::categoriesCategoryId($categoryId)
            ->km($kmFrom, $kmTo)->get();

Query Scope for the km -:

public function scopeKm($query, $kmFrom, $kmTo)
    {   
        if(($kmFrom) && ($kmTo)){
            return $query->whereBetween('km', ["$kmFrom", "$kmTo"]);   
        }
        return $query;
    }

Please assist

24th September, 2017

eddy1992 started a new conversation Laravel Not Returning Request • 8 months ago

I am trying to post this json http://jsoneditoronline.org/?id=4d930c11daaf8cd8bb6df6edbc446a1e object with base 64 and its returning empty array when I do $request->all();

31st August, 2017

eddy1992 started a new conversation Undefined Index Http_accept_language Laravel • 9 months ago

Hi I am facing an error when I trying to call a route on the remote server.

ErrorException in Controller.php line 25:
Undefined index: HTTP_ACCEPT_LANGUAGE
in Controller.php line 25
at HandleExceptions->handleError('8', 'Undefined index: HTTP_ACCEPT_LANGUAGE', '/home/devmzad/public_html/app/Http/Controllers/Controller.php', '25', array('request' => object(Request))) in Controller.php line 25
at Controller->__construct(object(Request))
at ReflectionClass->newInstanceArgs(array(object(Request))) in Container.php line 779
at Container->build('App\Http\Controllers\API\AdvFilterApiController', array()) in Container.php line 629
at Container->make('App\Http\Controllers\API\AdvFilterApiController', array()) in Application.php line 697
at Application->make('App\Http\Controllers\API\AdvFilterApiController') in ControllerDispatcher.php line 67
at ControllerDispatcher->makeController('App\Http\Controllers\API\AdvFilterApiController') in ControllerDispatcher.php line 52
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\API\AdvFilterApiController', 'getAddAdvFilters') in Route.php line 174
at Route->runController(object(Request)) in Route.php line 140
at Route->run(object(Request)) in Router.php line 724
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Checklang.php line 26
at Checklang->handle(object(Request), object(Closure))
at call_user_func_array(array(object(Checklang), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 726
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 54

Please any idea what is wrong with it. Please assist.

25th August, 2017

eddy1992 left a reply on Error Facing When Creating Columns Dynamically In A Table • 9 months ago

@Snapey Thank you. No the error looks like this http://imgur.com/ID3yIrY

eddy1992 started a new conversation Error Facing When Creating Columns Dynamically In A Table • 9 months ago

Hi I am creating columns dynamically in a table and facing a weird error. The page says

error GTO

error

when I am running the command to create a new column in the table.

The code where I am creating the columns -:

public function createColumn($column)
    {   
        DB::transaction(function () use ($column){
            $this->createColumnInProducts1($column);
            $this->createColumnInProducts4($column);
        });
    }


    public function createColumnInProducts1($column)
    {   
        Schema::table('products1', function ($table) use ($column) {
            $table->string($column);
        });
    }


    public function createColumnInProducts4($column)
    {
        Schema::table('products4', function ($table) use ($column){
            $table->string($column);
        });
    }

Please assist why its showing this error. On my local its working fine but on the server I am getting this error.

18th August, 2017

eddy1992 left a reply on Create Columns In A Table Dynamically • 10 months ago

Thanks @Cronix you are awesome cheers.

eddy1992 left a reply on Create Columns In A Table Dynamically • 10 months ago

@Dunsti No I want to add it dynamically through code.

eddy1992 started a new conversation Create Columns In A Table Dynamically • 10 months ago

Hi I want to know whether its possible to create columns dynamically in a table. For example If I have table named car and I have two columns , car_name, car_year and later on some condition I want to add columns dynamically like car_tyre, car_insurance in the table. If this is possible please let me know. Thanks.

11th August, 2017

eddy1992 started a new conversation How To Take Json As Input And Display In Laravel • 10 months ago

Hi I want to know whether I could take an array of json and store it in a table as a longText and retrieve it as json later on ? Is this the way to approach it ? if not then what will the ideal way to do it.

Right now in my database there is a table column named filterListValues which has a datatype longText.

I am coping the json ie is the value of the key filterListValues and pasting it in using an text area.

and later I am just getting the it as a string for this column.

"filterListValues": [
            {
              "filterListValuesId": "0",
              "filterListValuesNameEnglish": "All Types",
              "filterListValuesNameArabic": "All Types arabic",
              "filterListValuesImage": ""
            },
            {
              "filterListValuesId": "1",
              "filterListValuesNameEnglish": "Furnished",
              "filterListValuesNameArabic": "Furnished arabic",
              "filterListValuesImage": ""
            },
            {
              "filterListValuesId": "2",
              "filterListValuesNameEnglish": "Semi Furnished",
              "filterListValuesNameArabic": "Semi Furnished arabic",
              "filterListValuesImage": ""
            },
            {
              "filterListValuesId": "3",
              "filterListValuesNameEnglish": "Not Furnished",
              "filterListValuesNameArabic": "Not Furnished arabic",
              "filterListValuesImage": ""
            }
          ]

Please assist me on this. Thank you

9th August, 2017

eddy1992 left a reply on Base Table Or View Not Found: 1051 Unknown Table After Php Artisan Migrate:refresh • 10 months ago

@tykus Thank you for your response, I am using laravel 5.2 and I tried the option to drop all tables and run migrations again but gave me the same error.

eddy1992 started a new conversation Base Table Or View Not Found: 1051 Unknown Table After Php Artisan Migrate:refresh • 10 months ago

Hi I am facing an issue where I am trying to run php artisan migrate:refresh and every time I run my migration it gives me an error

[Illuminate\Database\QueryException]
  SQLSTATE[42S02]: Base table or view not found: 1051 Unknown table 'mzad-web.adv_filter_categories' (SQL: drop table `adv_filter_categories`)
 [PDOException]
  SQLSTATE[42S02]: Base table or view not found: 1051 Unknown table 'mzad-web.adv_filter_categories'

But when I go and check in the adminer I could see the tables have been dropped. After that If i run php artisan migrate it migrates the tables back again. The only issue is when I try to run php artisan migrate:refresh it gives me this error. Please assist

my migration files I have only two migration files -:

  1. This is the one which is shown in the error.
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAdvFilterCategoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('adv_filter_categories', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('category_id')->unsigned();
            $table->string('category_name_english');
            $table->string('category_name_arabic');
            $table->boolean('active')->default(1);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('adv_filter_categories');
    }
}


Please assist I am stuck with it for such a long time and not able to understand why tis happening.

Thank you

12th July, 2017

eddy1992 left a reply on Selected Option Not Working When Using V-model • 11 months ago

@tykus nope I do not have any errors in my browser.

eddy1992 left a reply on Selected Option Not Working When Using V-model • 11 months ago

@tykus no they have -:

<select class="form-control c-select" v-model="signUpUserTypeSelected" name="user_type" >
                <option disabled value="">Please select one</option>
                <option value="Parent">Parent</option>
                <option value="Student">Student</option>
                <option value="Teacher">Teacher</option>
            </select>

eddy1992 started a new conversation Selected Option Not Working When Using V-model • 11 months ago

Hi I have a select which looks like this -:

<select class="form-control c-select" v-model="signUpUserTypeSelected" name="user_type" >
                
                <option selected>Parent</option>
                <option>Student</option>
                <option>Teacher</option>
            </select>

Now the select selected option is not working on it please assist.

My app.js for signUpUserTypeSelected,

const app = new Vue({
    el: '#app',

    data: {
        signUpUserTypeSelected: '',
        signInUserTypeSelected: '',
    },

Please assist how will I solve this issue

eddy1992 started a new conversation Vue And Laravel Partials • 11 months ago

Hi I have a layout name app.blade.php which looks like this -:

<body>
    <div class="app white" id="app"> //I have mentioned this id in vue 
        @yield('content')
    </div>
</body>

I have mentioned a div with an id of app , Now I have two blades one is sign-up and other is sign-in

Sign-up.blade.php looks like this in which I have mentioned a v-model with a select -:

@extends('layouts.app') 

@section('title', 'sign-up')

@section('content')

<div class="col-sm-10">
            <select class="form-control c-select" v-model="signUpUserTypeSelected"          name="user_type" required>
                <option disabled value="">Please select one</option>
                <option>Parent</option>
                <option>Student</option>
                <option>Teacher</option>
            </select>
        </div>

and in app.js I have declared an empty data for signUpUserTypeSelected and everything works fine for the sign-up.blade.php-:

my app.js

const app = new Vue({
    el: '#app',
    data: {
        signUpUserTypeSelected: '',//this works fine in signup.blade.php
        signInUserTypeSelected: ''//this does not work in signin blade php
    },

So when I declare and create a new data named sing-in.blade.php

@extends('layouts.app')

@section('title', 'sign-up')

@section('content')

<div class="form-group">
      <select class="form-control c-select" v-model="signInUserTypeSelected" name="user_type" required>
        <option disabled value="">Login as</option>
          <option>Parent</option>
          <option>Student</option>
          <option>Teacher</option>
      </select>
    </div>

Now vue is giving me a warning for signInUserTypeSelected.

[Vue warn]: Property or method "signInUserTypeSelected" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.

(found in <Root>)

I guess I am doing something wrong with the partial and the id="app", Sorry I am new with vue js so I am struggling with this.

11th July, 2017

eddy1992 left a reply on Property Or Method "test" Is Not Defined On The Instance But Referenced During Render.... • 11 months ago

@lars6 thanks for your response but I tried it, It gave me the same error.

eddy1992 started a new conversation Property Or Method "test" Is Not Defined On The Instance But Referenced During Render.... • 11 months ago

Hi I am facing an error with vue, I have a Laravel 5.4 project and I installed and performed all the necessary steps to get laravel mix up and running. Now I am trying to perform a simple hello world using vue in my laravel project in app.js I am facing an warning

app.js:32213 [Vue warn]: Property or method "test" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.

(found in <Root>)

my app.js


/**
 * First we will load all of this project's JavaScript dependencies which
 * includes Vue and other libraries. It is a great starting point when
 * building robust, powerful web applications using Vue and Laravel.
 */

require('./bootstrap');

window.Vue = require('vue');

/**
 * Next, we will create a fresh Vue application instance and attach it to
 * the page. Then, you may begin adding components to this application
 * or customize the JavaScript scaffolding to fit your unique needs.
 */

Vue.component('example', require('./components/Example.vue'));

const app = new Vue({
    el: 'body',
    data: {
        test: 'hello world'
    }
});


and In the front end whenever I try to call @{{ test }} I am facing this warning and I am frustrated now Please assist.

7th July, 2017

eddy1992 started a new conversation Laravel Mix • 11 months ago

I am just trying to bundle all my js and css into one file. I assume its a good idea right ? Please correct me if I am wrong. Now my webpack.mix.js looks something like this -:

mix.js([

        'resources/assets/js/app.js',
        'public/js/plugins/tether/dist/js/tether.min.js',
        'public/js/plugins/jQuery-Storage-API/jquery.storageapi.min.js',
        'public/js/plugins/jquery-pjax/jquery.pjax.js',
        'public/js/plugins/blockUI/jquery.blockUI.js',
        'public/js/plugins/jscroll/jquery.jscroll.min.js',

    ], 'public/js/app.js')

    .scripts([

        'public/js/scripts/config.lazyload.js',
        'public/js/scripts/ui-load.js',
        'public/js/scripts/ui-jp.js',
        'public/js/scripts/ui-include.js',
        'public/js/scripts/ui-device.js',
        'public/js/scripts/ui-form.js',
        'public/js/scripts/ui-modal.js',
        'public/js/scripts/ui-nav.js',
        'public/js/scripts/ui-list.js',
        'public/js/scripts/ui-screenfull.js',
        'public/js/scripts/ui-scroll-to.js',
        'public/js/scripts/ui-toggle-class.js',
        'public/js/scripts/ui-taburl.js',
        'public/js/scripts/app-dev.js',
        'public/js/scripts/ajax.js',
        'public/js/scripts/flickity.pkgd.min.js',
        'public/js/scripts/index.js',
        'public/js/scripts/jquery.fancybox.js',

    ], 'public/js/app.js')

    .styles([

        'public/css/plugins/animate.css/animate.min.css',
        'public/css/plugins/glyphicons/glyphicons.css',
        'public/css/plugins/font-awesome/css/font-awesome.min.css',
        'public/css/plugins/material-design-icons/material-design-icons.css',
        'public/css/plugins/ionicons/css/ionicons.min.css',
        'public/css/plugins/simple-line-icons/css/simple-line-icons.css',
        'public/css/styles/bootstrap.min.css',
        'public/css/styles/app.css',
        'public/css/styles/style.css',
        'public/css/styles/font.css',
        'public/css/styles/jquery.fancybox.css',
        'public/css/styles/flickity.css',
        
    ], 'public/css/app.css')

   .sass('resources/assets/sass/app.scss', 'public/css');

But Its not working I must be doing something wrong please assist me on this as I new with laravel mix. Thank you.

eddy1992 started a new conversation Using Laravel Mix • 11 months ago

Hi I am new to laravel mix and bundle my assets. I have few html file like named index.html and signup.html and so on. When I see those html files source code I could see it is using many css and many third party css and js. For example it is using all these css -:

<link rel="stylesheet" href="css/animate.css/animate.min.css" type="text/css"/>
    <link rel="stylesheet" href="css/glyphicons/glyphicons.css" type="text/css"/>
    <link rel="stylesheet" href="css/font-awesome/css/font-awesome.min.css" type="text/css"/>
    <link rel="stylesheet" href="css/material-design-icons/material-design-icons.css" type="text/css"/>
    <link rel="stylesheet" href="css/ionicons/css/ionicons.min.css" type="text/css"/>
    <link rel="stylesheet" href="css/simple-line-icons/css/simple-line-icons.css" type="text/css"/>
    <link rel="stylesheet" href="css/bootstrap/dist/css/bootstrap.min.css" type="text/css" />
    <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
    
    <!-- build:css css/styles/app.min.css -->
    <link rel="stylesheet" href="css/styles/app.css" type="text/css" />
    <link rel="stylesheet" href="css/styles/style.css" type="text/css" />
    <!-- endbuild -->
    <link rel="stylesheet" href="css/styles/font.css" type="text/css" />
    <link rel="stylesheet" href="css/fancybox/jquery.fancybox.css" type="text/css" />
    <link rel='stylesheet prefetch' href="css/flickity/flickity.css">

and its using all these js files -:

<script src="libs/jquery/dist/jquery.js"></script>
<!-- Bootstrap -->
<script src="libs/tether/dist/js/tether.min.js"></script>
<script src="libs/bootstrap/dist/js/bootstrap.js"></script>
<!-- core -->
<script src="libs/jQuery-Storage-API/jquery.storageapi.min.js"></script>
<script src="libs/PACE/pace.min.js"></script>
<script src="libs/jquery-pjax/jquery.pjax.js"></script>
<script src="libs/blockUI/jquery.blockUI.js"></script>
<script src="libs/jscroll/jquery.jscroll.min.js"></script>

<script src="scripts/config.lazyload.js"></script>
<script src="scripts/ui-load.js"></script>
<script src="scripts/ui-jp.js"></script>
<script src="scripts/ui-include.js"></script>
<script src="scripts/ui-device.js"></script>
<script src="scripts/ui-form.js"></script>
<script src="scripts/ui-modal.js"></script>
<script src="scripts/ui-nav.js"></script>
<script src="scripts/ui-list.js"></script>
<script src="scripts/ui-screenfull.js"></script>
<script src="scripts/ui-scroll-to.js"></script>
<script src="scripts/ui-toggle-class.js"></script>
<script src="scripts/ui-taburl.js"></script>
<script src="scripts/app.js"></script>
<script src="scripts/ajax.js"></script>
<script src="scripts/plugins/flickity.pkgd.min.js"></script>
<script src="scripts/index.js"></script>
<script src="scripts/index.js"></script>
<script src="scripts/plugins/jquery.fancybox.js"></script>

Now what I see is these are a lot of js and css file, so my first question is should I add all these css and js folders in my laravel project and then compile of them to app.css and app.js using Laravel mix ? Is this how it is done ? and please correct me if I am wrong or suggest some more ideas about how should I proceed with it. Thank You.

23rd June, 2017

eddy1992 started a new conversation Vue 1 Or Vue 2 • 11 months ago

Hi I have just started to learn about vue 1 tutorial from laracast and I am enjoying every bit of it but I am concerned about one thing , should I invest on Vue 1 and learn it first or should I straight start with vue 2 ? What do you guys suggest ?

16th June, 2017

eddy1992 started a new conversation How To Get More Contents From Url Using Curl • 1 year ago

HI I have a function to get the contents from a url using the curl and its called file_get_contents_curl($url); Now the issue is I am getting only limited contents what we want to do is download more content, possible couple of paragraph and save it in our database.

function file_get_contents_curl($url) {
        $agent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
        curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
        curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_URL, $url);
        //curl_setopt($ch, CURLOPT_REFERER, $url);
        //curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/v1.0/?id='. urlencode($url). '&scrape=1');
        //curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        //curl_setopt($ch, CURLOPT_MAXREDIRS,10);
        //curl_setopt($ch, CURLOPT_NOBODY, true); 
        //curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');  
       
        curl_setopt($ch, CURLOPT_USERAGENT, $agent);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        //curl_setopt($ch, CURLOPT_VERBOSE, true);

        $data = curl_exec($ch);
        $info = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
        //$info = curl_getinfo($ch) ;
        $err = curl_error($ch);
        $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        $eff_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
        
        //checking mime types

        if(strstr($info,'text/html')) {
            curl_close($ch);
            return $data;
        } elseif(strstr($info,'text/plain')) {
            curl_close($ch);
            $data = shell_exec ('/usr/bin/curl' . ' ' . $url);
            return $data;
        } else {
            return false;
        }
    }

Please assist how will I achieve this behavior. Thank you.

13th June, 2017

eddy1992 started a new conversation Insert Into Db Using Array With Foreach • 1 year ago

Hi I have an array and I want to insert into the db now is there any way in which I could add the whole array to the db rather than doing foreach and looping and creating a new record.


$subjects = ['physics', 'maths', 'science', 'politics', 'engineering'];
foreach($subjects as $subject) {
    App\Subject::create['name' => $subject]);  // I dont want to do for each now. 
}

So what if I dont want to foreach and create a new record ? Please assist.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.