Monday, 7 May 2018

Date Format to Template and Validation

At Validation

  'dob' => 'required|date_format:"d/m/Y"|before:"2006-01-01"',

At View Template

  {{$submissions->created_at->format("F d, Y")}}





Saturday, 5 May 2018

Return Old Input After Validation

From Controller (UserController)

  $validator = Validator::make($request->all(), [
          'first_name' => 'required|max:100',
          'last_name' => 'required|max:100',
          'gender' => 'required|numeric',
          'dob' => 'required|date|before:"2006-01-01"',
          'email' => 'required|email',
          'mobile' => 'required|numeric',
          'street' => 'required|max:255',
          'city' => 'required|alpha|max:20',
          'state' => 'required|numeric',
          'post_code' => 'required|numeric',
      ], $messages);

      if ($validator->fails()) {
          return redirect()->back()

Thursday, 3 May 2018

Laravel Custom Login Validation

   public function __construct()

  * Get the failed login response instance.
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\RedirectResponse
  protected function sendFailedLoginResponse(Request $request)
      $errors = [$this->username() => trans('auth.failed')];
      // Load user from database
      $user = \App\User::where($this->username(), $request->{$this->username()})->first();
        $errors = ['email' => 'Invalid Email. Please try again'];
        // Check if user was successfully loaded, that the password matches
        // and active is not 1. If so, override the default error message.
        if (!Hash::check($request->password, $user->password)) {
            $errors = ['password' => 'Invalid Password. Please Try again'];


      if ($request->expectsJson()) {
          return response()->json($errors, 422);
      return redirect()->back()
          ->withInput($request->only($this->username(), 'remember'))

Reference :

Monday, 30 April 2018

Redirected after Login or Register

in Login Controller, it was located under Illuminate\Foundation\Auth\AuthenticatesUsers;

then change this function to :

     * The user has been authenticated.
     * @param  \Illuminate\Http\Request  $request
     * @param  mixed  $user
     * @return mixed
    protected function authenticated(Request $request, $user)
      return redirect('/admin');

while for Register Controller, it was located under Illuminate\Foundation\Auth\RegistersUsers;

then change this function to : 

     * The user has been registered.
     * @param  \Illuminate\Http\Request  $request
     * @param  mixed  $user
     * @return mixed
    protected function registered(Request $request, $user)
        return redirect('/admin');

however RegisterController has a constant variable   protected $redirectTo = '/home'; which you can just change their value to your target url.


Saturday, 28 April 2018

Friday, 27 April 2018

Merging Input Request

Often you want to pass value for input type hidden, this can be submitted by merging with another form request to the controller


Wednesday, 25 April 2018

Layer 1 - Physical Layer

Ethernet and Ethernet based cables to make L1 connection happer.


- speeds , cap
- including unshielding twisted-pair (utp) , shielding twisted copper (stp)
- twisting cables minimize the effect of EMI from outside sources
- twisting cables lessens the amount of EMI from going out from cable itself.
- stp easily damaged and cost more
- fibre optic is cost more from copper cable
- have a maximum cable of 100 meters
- switching between ethernet speeds and capabilities would be not problem because
ethernet has standards as below.

copper based standards :
- regularly runs at 10 Mbps
- IEEE name :  10BASE-T
- fast ethernet, clocking at 100Mbps, IEEE name standard is 802.3u (100Base-T)
- normal Ethernet and fast Ethernet use only two pair  of wires out of the four available
- Gigabit Ethernet, bringing 1000Mbps, IEEE name stnadard 802.3ab (1000Base-T)
- while gigabit ethernet use all four pair of wires in the cable
- 10 Gig Ethernet runs at 10Gbps, IEEE name standard is 802.3an (10GBase-T)

the fibre optic standard :
- fiber standards jump right to Gigabit Ethernet, running at 1000Mbps
- network admins call it 1000Base-LX, while IEEE standard is 802.3z

Cable Types 

Crossover and straight through cabling
- for the host to switch connections, we'll need straight through cables, so named because the wires in the cable run straight from a particular pin at the host end to the same numbered pin at the switch end.

-whilst switch to swith connection using crossover cable since transmit ports and receive port needed to be different at one end pin.

- Auto MDI-X  (Automatic Medium-Dependent Interface Crossover), eventually cisco switch got automatic discover cable if newly straight-through cable were set up between two switch. You need to set cisco switch port, set speed, duplex and mdix to auto that port.

**auto mdi-x formula*
same device = crossovercable
not same type of devices = straight-through cable

SW1(config)#int fast 0/1
SW1(config-if)#speed auto
SW1(config-if) #duplex auto
SW1(config-if)#mdix ?
auto Enable automatic MDI crossover detection on this interface
SW1(config-if)#mdix auto

Ethernet Header

Preamble | Start Frame Delimiter (SFD) | Dest. MAC Address | Source MAC Address | Protocol Type

1. Preamble : A seven-byte set of alternating ones and zeroes 10101010, repeated seven times. Used for clock synchronization.

2. SFD : One-byte field set to 10101011, used to indicate preamble's end and that the destination MAC address will immediately follow.

3. Destination MAC Address : The frame's destination.

4. Source MAC address : The frame's  source

5. Protocol Type : Can be IPV4 protocol and occasionally IPV6.

Ethernet Trailer

1. Frame Check Sequence (FCS)
- strictly for error detection, 
2. Cyclic Redundancy Check ( a complex mathematical operation )
- sender arrives at a value by running a cyclic redundancy check against the data contained in the frame, resulting in a numeric value. that value is placed into FCS and the frame is then transmitted.
- the recepient of the frame will run the same CRC against frame's data and compares the answer to that contained in incoming CRC. if the compared values are the same, the frame is non-corrupt and life goes on. otherwise the frame is corrupted and will be discarded.


Also known as single collision domain.
Now to prevent the loss of data and time associated with collisions, Carrier Sense Multiple Access
with collision detection (CSMA/CD) was developed. Here's the CSMA/CD process:

1. before sending data, a host will check to see if any other host is already sending data.

2. if that check reveals another host is sending data, the host backs off for a few miliseconds before it listens to the same wire again. If no one's sending data, the host sends the data signal.

3. if 2 PCs happen to send data at the exact time after listening to the wire, the voltage on the wire itself changes, signaling to the hosts that a data collision has occured.

4. The PCs that sent the data will generate a jam signal, indicating to other hosts that data should not be transmitted at this time.

Disadvatages of hub :

1. high level of delay sensitivity when handling voice and video traffic. (one big collision domain)

2. every single time a host connected to this hub sends a broadcast, every other host on that hub will receive a copy of that broadcast. there is no other way to limit the scope of the broadcast and preventing the unnecessary spreading (propagation) of a broadcast through network.

Quick Review

1. hubs give us one collision domain consisting of all connected hosts, one broadcast domain containing those same hosts, and allow only one host to transmit a time.

2. bridges allow us to logically segment the network and to lessen the size of collision domains, but do nothing to segment broadcast domains.

3. switches bring us one-host collision domains and the capability to logically segment the broadcast domain, although that's not done by defa  ult.