Skip to content

Instantly share code, notes, and snippets.

View Sarav-S's full-sized avatar

Sarav Sarav-S

View GitHub Profile
@extends('layouts.app')
@section('content')
<div class="container">
@if(session()->has('status'))
<p class="alert alert-info">
{{ session()->get('status') }}
</p>
@endif
<div class="col-sm-6 col-sm-offset-3">
/**
* Remove the specified resource from storage.
*
* @param App\User $user
* @return \Illuminate\Http\Response
*/
public function destroy($user)
{
if ($user->delete()) {
session()->flash('status', 'User deleted successfully');
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param App\User $user
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $user)
{
$this->validate($request, $this->rules($user->id));
laravel new crud
@extends('layouts.app')
@section('content')
<div class="container">
@if(session()->has('status'))
<p class="alert alert-info">
{{ session()->get('status') }}
</p>
@endif
<div class="panel panel-default">
<?php
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$users = User::latest()->paginate();
<?php
// During table creation
$table->integer('address_id')->unsigned()->index();
// Or during updation
$table->index('address_id')
@Sarav-S
Sarav-S / migration.php
Last active November 13, 2019 10:58
Foreign Key Reference
<?php
$table->foreign('user_id')
->references('id')->on('users')
->onUpdate('cascade')
->onDelete('cascade');
@Sarav-S
Sarav-S / helpers.php
Last active September 23, 2016 02:10
bcrypt() function
<?php
if (! function_exists('bcrypt')) {
/**
* Hash the given value.
*
* @param string $value
* @param array $options
* @return string
*/
@Sarav-S
Sarav-S / HashServiceProvider.php
Last active September 23, 2016 02:10
HashServiceProvider registers the hash key
<?php
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->singleton('hash', function () {