abdulrafey38

abdulrafey38

Member Since 6 Months Ago

Lahore

Experience Points
980
Total
Experience

4,020 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.

Level 1
980 XP
Aug
25
3 weeks ago
Activity icon

Started a new Conversation Throw Validation Exception Wont Work

Look at the code below when i enter correct credentials it gives me token and user details which is correct but when I enter wrong credentials it does not give me throw exception "credentials not match" instead it redirects to laravel default home page


namespace App\Http\Controllers;
use Validator;
use App\User;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\ValidationException;
use Illuminate\Http\Request;

class apiController extends Controller
{
    public function login (Request $request)
    {
        $validator = Validator::make($request->all(), [
            
            'email' => 'required|email',
            'password' => 'required',
      
        ]);
        if ($validator->fails()) {
            return response()->json(['error'=>$validator->errors()], 401);
        }
    
        $user = User::where('email', $request->email)->first();
    
        if (! $user || ! Hash::check($request->password, $user->password)) {
            throw ValidationException::withMessages([
                'email' => ['The provided credentials are incorrect.'],
            ]);
        }
    
        return response(['user'=>$user,'token'=>$user->createToken('MY APP')->plainTextToken],201);
    }
Aug
18
1 month ago
Activity icon

Replied to Laravel Eloquent With Vue

@sinnbeck what if i want to just update the values all the time also the insert method works fine for the first time but not after

Activity icon

Replied to Laravel Eloquent With Vue

@sinnbeck thanks It works

Activity icon

Replied to Laravel Eloquent With Vue

@sinnbeck not working also if i want to print $request->stockPortfolio it shows nothing too but when I print $request it shows the array which I write above in my answer

Activity icon

Started a new Conversation Laravel Eloquent With Vue

Below is my request that is basically a post request from vue using axios

{"funds":9560,"stockPortfolio":[{"id":1,"quantity":"4","name":"BMW","price":110}],"stocks":[{"id":1,"name":"BMW","price":110},{"id":2,"name":"Google","price":120},{"id":3,"name":"Apple","price":210},{"id":4,"name":"Twitter","price":190},{"id":5,"name":"Facebook","price":310}]}

I am trying to save it into my database tables 1 is Funds table in which funds save that works ok as its a single value, but other 2 stock and stockportfolio have an associate array with than how to save them in their respective tables My try is given below

public function store(Request $request){
        error_log($request);
        
        $fund = Fund::find(1);
        $fund->funds = $request->funds;
        $fund->save();

        Stock::create($request->stocks->all());
        Portfolio::create($request->stockPortfolio->all());
        return (new stockResource($fund))
                ->response()
                ->setStatusCode(201);
 


    }

funds in working fine but other two's are not

Aug
10
1 month ago
Activity icon

Replied to Validations

Here is the migration @sinnbeck

   public function up()
    {
        Schema::create('section_courses', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('section_id');
            $table->integer('course_id');
            $table->integer('faculty_id');
            $table->timestamps();
        });
    }
Activity icon

Replied to Validations

here it is @sinnbeck

SQLSTATE[HY000]: General error: 1364 Field 'id' doesn't have a default value (SQL: insert into `section_courses` (`section_id`, `course_id`, `faculty_id`, `updated_at`, `created_at`) values (1, 1, 6, 2020-08-10 21:07:21, 2020-08-10 21:07:21))

and if I allow files id to be null by default it stores data with null value in id (primary key)

Activity icon

Replied to Validations

Here it is @sinnbeck

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class SectionCourse extends Model
{

    // students
    public function students()
    {
        return $this->belongsToMany(User::class, 'student_sections', 'section_id', 'student_id');
    }


    public function sectionName()
    {
        return $this->belongsTo(Section::class, 'section_id', 'id');
    }

    public function course()
    {
        return $this->belongsTo(Course::class, 'course_id', 'id');
    }

    public function faculty()
    {
        return $this->belongsTo(Instructor::class, 'faculty_id', 'id');
    }
}
Activity icon

Replied to Validations

Here it is @sinnbeck

 public function storeSection(Request $request)
    {
        $section_id = $request->input('section_id');
        $course_id = $request->input('course_id');
        $faculty_id = $request->input('faculty_id');
        

        $validate = Validator::make($request->all
(), [
            'course_id' => 'required',
            'faculty_id' => 'required',
            'section_id' => 'required',
            'custom_validation'   => Rule::unique('section_courses')->where(function ($query) use($section_id,$course_id, $faculty_id) {
                return $query->where('section_id', $section_id)
                ->where('course_id', $course_id)->where('faculty_id', $faculty_id);
            }),
    ],
        [
            'section_id.required' => 'Please select the Section.',
            'course_id.required'  => 'Please select the Course.',
            'faculty_id.required' => 'Please select Faculty.',
            'custom_validation.unique'   => 'Teacher Already Assign to Same Section!!'
]);

        if ($validate->fails()) {
            return redirect()
                ->back()->withErrors($validate)->withInput();
        }
        $new = new SectionCourse();
        $new->section_id = $request->section_id;
        $new->course_id = $request->course_id;
        $new->faculty_id = $request->faculty_id;
        $new->save();

        return redirect()->back()->with(['success' => 'Added successfully.']);
    }
Activity icon

Replied to Validations

now its says that id column dont have a default value, if I allow null for id column it again save but in it put null in id coumn

Activity icon

Replied to Validations

@sinnbeck hope you may understand now

Activity icon

Replied to Validations

ok this checks only section_id and if its unique it doesn't allow to put data in DB, WHAT I WANT IS IF THE all three columns have unique values at the same time it not allow it to put In DB Example here:

section_id	course_id	faculty_id
      1	            1                 1 
      2             2                 1
      3             3                 2
      1             1                 1 Not allowed as this already exists
      2             2                 1 Not allowed as this already exists
      5             1                 1
Activity icon

Started a new Conversation Validations

(Still Unsolved) I want to put a validation where combination of three columns (section_id, course_id, faculty_id) if repeated is not allowed, how to acheive it

        $validate = Validator::make($request->all(), [
            'section_id' => 'required',
            'course_id' => 'required',
            'faculty_id' => 'required',
	    'u_id'=>'unique: ?'


        ], [
            'section_id.required' => 'Please select the Section.',
            'course_id.required'  => 'Please select the Course.',
            'faculty_id.required' => 'Please select Faculty.',
            'u_id.unique'   => 'Teacher Already Assign to Same Section!!'


        ]);
        if ($validate->fails()) {
            return redirect()
                ->back()->withErrors($validate)->withInput();
        }
Activity icon

Started a new Conversation Validations

I want to put a validation where combination of three columns (section_id, course_id, faculty_id) if repeated is not allowed, how to acheive it

        $validate = Validator::make($request->all(), [
            'section_id' => 'required',
            'course_id' => 'required',
            'faculty_id' => 'required',
	    'u_id'=>'unique: ?'


        ], [
            'section_id.required' => 'Please select the Section.',
            'course_id.required'  => 'Please select the Course.',
            'faculty_id.required' => 'Please select Faculty.',
            'u_id.unique'   => 'Teacher Already Assign to Same Section!!'


        ]);
        if ($validate->fails()) {
            return redirect()
                ->back()->withErrors($validate)->withInput();
        }
Aug
09
1 month ago
Activity icon

Replied to Validations

@sinnbeck i already tried it in this way, its not working in my case

Activity icon

Started a new Conversation Validations

I want to put a validation where combination of three columns (section_id, course_id, faculty_id) if repeated is not allowed, how to acheive it.


        $validate = Validator::make($request->all(), [
            'section_id' => 'required',
            'course_id' => 'required',
            'faculty_id' => 'required',


        ], [
            'section_id.required' => 'Please select the Section.',
            'course_id.required'  => 'Please select the Course.',
            'faculty_id.required' => 'Please select Faculty.',
            'u_id.unique'   => 'Teacher Already Assign to Same Section!!'


        ]);
        if ($validate->fails()) {
            return redirect()
                ->back()->withErrors($validate)->withInput();
        }
Jul
28
1 month ago
Activity icon

Awarded Best Reply on Composer Require Laravel/ui Not Working

changing the laravel version to the latest solved the issue. Thanks All of you.

Activity icon

Replied to Composer Require Laravel/ui Not Working

changing the laravel version to the latest solved the issue. Thanks All of you.

Jul
27
1 month ago
Activity icon

Started a new Conversation Composer Require Laravel/ui Not Working

The composer command "composer require laravel/ui" not working. Shows this error


Installation failed, reverting ./composer.json to its original content.

Apr
24
4 months ago
Activity icon

Replied to Laravel Test Folder

@snapey I am new to laravel and i recently created a complete project in laravel and i even dont touch test folder so can you please tell me when i need that folder thanks in advance.

Activity icon

Started a new Conversation Laravel Test Folder

Whats the purpose of Test folder in laravel does ever i need it in development purpose or its just a laravel thing.

Apr
21
4 months ago
Activity icon

Replied to Validator Issue

Thanks

Activity icon

Started a new Conversation Validator Issue


    public function sectionStore(Request $request)
    {
        $validate = Validator::make($request->all(), [

            'name' => 'unique:sections',
        ], [
            'name.unique' => 'This Section has Already exist.',

        ]);

        $secStore = new Section();
        $secStore->name = $request->name;
        $secStore->save();

        return redirect('/section/view')->with(['success' => 'Section added successfully.']);
    }

Hi guys i am trying to get unique section name to store in the db, i am trying to use this validation method but its not work for me here, but the same syntax do work with other database table, why its not working on my sections table

Apr
20
4 months ago
Activity icon

Started a new Conversation Help Needed In Stroing Data Laravel


    public function programstore(Request $request)
    {

        $new = new Program();
        $new->name = $request->name;
        $new->department_id = $request->department_id;
        $new->save();

        $newS = new Semester();
        for($i =1; $i<=8;$i++)
        {
            $newS->name = "Semester +$i";
            $newS->program_id = $newS->programs()->id;
        }

        return redirect()->back()->with(['success' => 'Added successfully.']);
    }

I need some help regarding storing data in databases as you can see i save data in programs table in database which is going correct but in the same store method i want to add data in semester table too because if i create a program in database its semester with program id should be automatically sent to database, now how to fetch the id of program which i just store and how to pass it into semester folder

        $newS = new Semester();
        for($i =1; $i<=8;$i++)
        {
            $newS->name = "Semester +$i";
            $newS->program_id = $newS->programs()->id;
        }

Activity icon

Replied to Laravel Choosing One Column In Database Conditionally

Model::select(DB::raw('query'))->get();

Apr
19
5 months ago
Activity icon

Replied to Composer Personal Acces Token

Thanku i got it how to set it by the way can you please tell why we need them in laravel? Can we use it to access api from GitHub ?

Activity icon

Started a new Conversation Composer Personal Acces Token

How can i place my own GitHub personal access token in my laravel project.

Activity icon

Replied to __construct In Laravel Controllers

Thanks appreciated

Activity icon

Replied to __construct In Laravel Controllers

Thanks Appreciated I got it know plus can you tell me that can i put more than one actions or method in except ().

Activity icon

Replied to __construct In Laravel Controllers

can we add more than one method in except()

Activity icon

Started a new Conversation __construct In Laravel Controllers

    public function __construct()
    {
        $this->middleware('auth:instructor')->except('attendanceShowToStudent');
    }

Can anyone here please explain me whats the purpose of __construct() in laravel and what in the above code __construct() do, and what about except() whats the purpose of it.

Apr
17
5 months ago
Activity icon

Replied to Need A Delay Between Login And Again Login

Bro every student have application install in their mobile phone they just login to their account on application select course and just scan qr code to mark Attendance as soon as they scan qr code their attendance is saved into db, i also managed to create a php script that stores attendance information to db that if the generated qr code timestamp is less less than my time limit than only it store Attendance, but now i only have one problem left if a student can login another student (which is not physically present in class) account from his application he will be able to mark that student Attendance too, hkw i can overcome this issue, i asked for delay in logins because i already set a timelimt after generation of qr code that after qr code is generated student have 2 min only to mark Attendance after 2 min qr code become invalid, so i need atleast 2 min Delay between two consecutive logins

Activity icon

Started a new Conversation Need A Delay Between Login And Again Login

I created an application for student to mark their attendance by Scanning qr code from that application, now i want login delay for that application for some security reasons, what i actually need is if a user login into application than he cannot be able to login again with the application for some time limit how to acheive it. Because if i dont implement this than a student can login in others student account and mark their Attendance too. Plus i use volley library with php script to login and other crud operations for my application.

Apr
16
5 months ago
Activity icon

Replied to Date And Time Getting But Not From By PC

Thanks appreciated

Activity icon

Started a new Conversation Date And Time Getting But Not From By PC

Hey, guys i need some help regarding my project, i need to get time and date in php which returns result not from my pc or system but from an online authentic source, because i created a system in which correct time and date is necessary for some security reasons, but if someone changes time in his/her system he/she can get that information after expiration time too.

Apr
10
5 months ago
Activity icon

Replied to QR Code In Laravel

I have a comma separated string of parameters in my qr code which i have to extract on my Android side than split it on the basis of comma and put it into database plus i am a beginner to laravel

Activity icon

Started a new Conversation QR Code In Laravel

Hi guys, i need some help regarding my project. I want to generate a qr code which students can scan from their mobile application to mark attendance, i am successfully able to generate a qr code but now i want to limit it for 2 or 3 minutes to be valid after that it will destroy for some security purposes how to achieve it, because uptil now if some person clicks the image of QR code and use it after some time his/her Attendance submitted successfully even after a day. I use laravel technology for web Portals and Android studio for my mobile application