Haseeb69

Member Since 1 Month Ago

Experience Points
570
Total
Experience

4,430 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
0
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

  • Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 1
570 XP
Apr
25
3 weeks ago
Activity icon

Replied to Does Laravel Sail Setup Cron For Schelations?

how did u get your crontab running after this ? most of the solutions i see recommend using CMD cron -f tail ... at the end of the file how did u do the same in laraval sail docker file ? your answer will really help me , thanks

Apr
22
3 weeks ago
Activity icon

Started a new Conversation Issues With Docker Compose

im dockerizing my laravel app i build my image using

sudo docker build -t werifier . command here's my docker file


FROM php:7.4-cli
WORKDIR /var/www/html
RUN apt-get update
RUN apt-get install -y git
 
RUN git clone *my project url here*

WORKDIR /var/www/html/werifier-frontend/
RUN chmod 777 -R ./storage && chmod 777 -R ./bootstrap/cache && chmod 777 -R ./public/images/pictures && chmod 777 -R ./storage/logs
RUN apt update && apt upgrade
RUN apt install curl
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install pdo pdo_mysql
RUN apt install zip unzip
RUN composer install 
RUN composer global require laravel/installer
RUN php artisan cache:clear 
RUN php artisan config:clear
EXPOSE 8000
CMD php artisan serve --host=0.0.0.0 --port=8000

if i run my container using sudo docker run -d -p 8000:8000 werifier it runs successfully

however im tryna make a network volume etc so im using docker-compose file

when i use docker-compose up it runs but nothing shows up i get connection was reset error and in my logs im getting

Starting Laravel development server: http://0.0.0.0:8000

[Thu Apr 22 10:19:07 2021] PHP 7.4.16 Development Server (http://0.0.0.0:8000) started

and nothing else

what seems to be the issue

#note im not using laravel sail

im tryna make this for production

here's my docker-compose file

version: '3'
services:
    werifier:
        image: werifier
        ports:
            - '8000:80'
        networks:
            - wefnetwork
        depends_on:
            - mysql
        
    mysql:
        image: 'mysql:8.0'
        ports:
            - '3306:3306'
        environment:
            MYSQL_ROOT_PASSWORD:
            MYSQL_DATABASE: 'werifier'
            # MYSQL_USER: '${DB_USERNAME}'
            # MYSQL_PASSWORD: '${DB_PASSWORD}'
            MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
        restart: always
        volumes:
            - 'sailmysql:/var/lib/mysql'
        networks:
            - wefnetwork
        healthcheck:
          test: ["CMD", "mysqladmin", "ping"]
    phpmyadmin:
        image: phpmyadmin/phpmyadmin
        links:
            - mysql:mysql
        ports:
            - 8080:80
        restart: always
        environment:
            # MYSQL_USERNAME: "${DB_USERNAME}"
            MYSQL_ROOT_PASSWORD:
            MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
            PMA_HOST: mysql
        networks:
        - wefnetwork
networks:
    wefnetwork :
        driver: bridge
volumes:
    sailmysql:
        driver: local
Apr
21
3 weeks ago
Activity icon

Replied to Laravel Schedule/CRON Woes

if you're running that on server then mayb you're getting blocked by server i guess? run php artisan schedule:work here and see if that works now though

Activity icon

Replied to Laravel Schedule/CRON Woes

php artisan schedule:list

if u see your commands here

then mayb edit your commands like this

    $schedule->command('wellbeing:heartbeat')
        ->everyMinute()
        ->evenInMaintenanceMode()
        ->runInBackground();

u can even try commenting one of these scheduled commands and check again

Activity icon

Replied to Laravel Schedule/CRON Woes

your synxtax is correct

mayb try this ?

composer require guzzlehttp/guzzle

Activity icon

Replied to Laravel Schedule/CRON Woes

had similar issues once but i don't remember how i fixed it However u can try following php artisan cache:clear sudo chmod -R 777 ./storage

Activity icon

Started a new Conversation Giving Permissions To Storage Folder Using Laravel Sail

This is my default docker file generated from sail package i'm new to docker and i don't know when exactly the project is copied into /var/www/html directory to execute the permission

where do i put my permissions here's my docker file

FROM ubuntu:20.04

LABEL maintainer="Taylor Otwell"

ARG WWWGROUP

WORKDIR /var/www/html

ENV DEBIAN_FRONTEND noninteractive
ENV TZ=UTC

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update && apt-get install -y cron
RUN apt-get update \
    && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 \
    && mkdir -p ~/.gnupg \
    && chmod 600 ~/.gnupg \
    && echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf \
    && apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E5267A6C \
    && apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C300EE8C \
    && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu focal main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \
    && apt-get update \
    && apt-get install -y php8.0-cli php8.0-dev \
       php8.0-pgsql php8.0-sqlite3 php8.0-gd \
       php8.0-curl php8.0-memcached \
       php8.0-imap php8.0-mysql php8.0-mbstring \
       php8.0-xml php8.0-zip php8.0-bcmath php8.0-soap \
       php8.0-intl php8.0-readline \
       php8.0-msgpack php8.0-igbinary php8.0-ldap \
       php8.0-redis \
    && php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
    && curl -sL https://deb.nodesource.com/setup_15.x | bash - \
    && apt-get install -y nodejs \
    && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
    && echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
    && apt-get update \
    && apt-get install -y yarn \
    && apt-get install -y mysql-client \
    && apt-get install -y postgresql-client \ 
    && apt install nano \
    && apt-get -y autoremove \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN apt-get update && apt-get install -y cron

RUN pecl install swoole

RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.0
RUN groupadd --force -g $WWWGROUP sail
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail

COPY start-container /usr/local/bin/start-container
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY php.ini /etc/php/8.0/cli/conf.d/99-sail.ini
 
RUN chmod +x /usr/local/bin/start-container

COPY crontab /etc/cron.d/crontab
RUN chown /etc/cron.d/crontab \
    && crontab /etc/cron.d/crontab \
    && touch /var/log/cron.log

RUN cd /var/www/html && service cron start 

RUN cd /var/www/html && chmod 777 -R ./storage && chmod 777 -R ./bootstrap/cache && chmod 777 -R ./public/images/pictures 

EXPOSE 8000

ENTRYPOINT ["start-container"]
Apr
15
1 month ago
Activity icon

Started a new Conversation Get Detailed Information On Record

i have three tables Permit ( pid, userid , companionid) , User(id,name etc) , Companion(cid, userid1,userid2,userid3,userid4 which are foreign keys to user table)

here are my relations in models

Permit:

    public function user()
    {
    return $this->belongsto(User::class,'userid','id');       
    }
    public function companion()
    {
    return $this->belongsto(Companion::class,'companionid','comid');        
    }

User:

  public function permits()
    {
        return $this->HasMany(Permit::class,'id','userid');
    }
    public function companions()
    {
        return $this->HasMany(Companion::class,'id','userid1')->HasMany(Companion::class,'id','userid2')->HasMany(Companion::class,'id','userid3')->HasMany(Companion::class,'id','userid4');
    }

Companion:

    public function permit()
    {
        return $this->HasMany(Permit::class,'comid','companionid');
    }
    public function user()
    {
    return $this->belongsto(User::class,'userid1','id')
    ->belongsto(User::class,'userid2','id')
    ->belongsto(User::class,'userid3','id')
    ->belongsto(User::class,'userid4','id');        
    }

The response i get from running this eloquent query

    $userinfo = Permit::with('user')->with('companion')->with('user')->where('pid', $pid)->where('userid', $id)->first();
            return $userinfo;
    

json response

{
pid: 14,
userid: "12345",
timeofvisit: "22:36:00",
dateofvisit: "2021-04-15",
registrationtype: "No Vehicle",
companionid: 2,
user: {
	id: "12345",
	idtype: "Citizen",
	usertype: 0,
	phone: "92213123123",
	fname: "xyz",
	DOB: "2021-04-21"
	},
companion: {
	comid: 2,
	userid1: "1",  i want this detailed info 
	userid2: "2",  i want this detailed info
	userid3: "3",  i want this detailed info
	userid4: null  
}
}

please look at the json response and tell me how can i achieve that Also i know my relations are really bad and i need suggestions on improving p,s no hate im a newbie

Apr
14
1 month ago
Activity icon

Started a new Conversation Laravel Sail Up Command Inside Docker File

im trying to dockerize my laravel app i know about laravel sail and stuff but im trying to run laravel sail command from inside docker file

FROM php:7.4-cli
WORKDIR /home/
RUN apt-get update
RUN apt-get install -y git
 
RUN git clone #myprojecturl
WORKDIR /home/#myprojectnamehere/
RUN apt update && apt upgrade
RUN apt install curl
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install pdo pdo_mysql
RUN apt install zip unzip
RUN composer install  

RUN composer global require laravel/installer
RUN php artisan cache:clear 
RUN php artisan config:clear
RUN ./vendor/bin/sail --no-cache
EXPOSE 8000
CMD ./vendor/bin/sail up -d
``

i get docker not found error here since im not using sudo is there any way around it what's the correct way to use sail inside docker file

Apr
13
1 month ago
Activity icon

Replied to Comparing Time In Eloquent

thanks for suggestion guys i've optimized my query but my original query was correct as well lol

Activity icon

Started a new Conversation Comparing Time In Eloquent

i have a timeofvisit field in table permits of time type (e.g 14:45:00 )

i'm trying to get all records where time is less than current time but im not getting any . AM i using this right?

$permitsdata1 = Permit::whereRaw('Time(timeofvisit) <= CURRENT_TIME()')->get();

Apr
12
1 month ago
Activity icon

Replied to Sql Errors On Laravel Docker

thanks bro a simple explanation just solved my concerns i configured sail with phpmyadmin and i found a better approach

Activity icon

Replied to Sql Errors On Laravel Docker

Is there anyway to solve my problem apart from using sail bro?

Apr
11
1 month ago
Activity icon

Started a new Conversation Sql Errors On Laravel Docker

i wanted to dockerize my laravel app. However laravel sail does not explain in any way how to configure your database after running migrations . Anways i gave up on sail as followed some tutorials

i launched two containers of mysql and php like this

sudo docker pull mysql/mysql-server:latest
sudo docker run --name=mysql  -e MYSQL_ROOT_PASSWORD=mypass -d mysql/mysql-server:latest

sudo docker pull phpmyadmin/phpmyadmin:latest
sudo docker run --name phpmyadmin -d --link mysql:db -p 8081:80 phpmyadmin/phpmyadmin

so i configured my user and imported my db manually in phpmyadmin

i launch my laravel container using my docker file etc

#some other code ...
EXPOSE 8000
CMD php artisan serve --host=0.0.0.0 --port=8000

my env file

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:aS838/4/6V7n9VQXDUdiQBDxDiM7sWhSc1ym0KahcZY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mydb
DB_USERNAME=root
DB_PASSWORD=mypass

if i keep db_host as 127.0.0.1 i get connection refused error if i give db_host as mysql(which is my running mysql container name) i get pdo errors if i give db_host as localhost i get not found errors i saw on few stackoverflow fixes that u have to give your local network ips instead i dont wanna do it cause i have my own reasons any way around this? i'm stuck on this for 2 days now and im depressed af .any help will be appreciated

Apr
06
1 month ago
Activity icon

Replied to Nullable Foreign Key In Laravel 8

baby rage lul

Activity icon

Started a new Conversation Nullable Foreign Key In Laravel 8

im getting error foreign key constraints incorrectly formed

here's my code

USER table
         
$table->string('id',15)->primary();  

COMPANION TABLE 
​
​​          $table->integer('comid')->primary();      
            $table->string('userid1',15)->nullable(); 
            $table->string('userid2',15)->nullable();
            $table->foreign('userid1')->references('id')->on('users')->onDelete('set null'); 
            $table->foreign('userid2')->references('id')->on('users')->onDelete('set null');  

cant make migration even without nullable method . any help will be appreciated
Mar
18
1 month ago
Activity icon

Started a new Conversation Node Child Process To Laravel Process Conversion

hello there i'm learning laravel i was working in node js app but i wanna do same thing in laravel i read the documentation but cant seem to get my head around this prob

need to convert this node code to laravel. Thanks var child = require('child_process') execFile child('/iniciaStream sh', [ para1,para2 ]);