Snippets Collections
// Display Object or Array
public function oa($model)
{
    if (gettype($model) === 'object') {
        dump(get_class($model));
        dump($model->toArray());
    } else {
        dump(gettype($model));
        dump($model);
    }
}
// Display string
public function s($model)
{
    dump($model);
}
In terminal excute the following command
1. composer require hardevine/shoppingcart
Then in app.php in config folder write the following code in providers array
Gloudemans\Shoppingcart\ShoppingcartServiceProvider::class,
 and in aliases array
 'Cart' => Gloudemans\Shoppingcart\Facades\Cart::class,
2. Now in terminal execute the following command
php artisan vendor:publish --provider="Gloudemans\Shoppingcart\ShoppingcartServiceProvider" --tag="config"
3. Now in ShopComponent class file at head write the following
use Cart;
then in ShopComponent write the following function
 public function store($product_id, $product_name, $product_price)
    {
        Cart::add($product_id, $product_name, 1, $product_price)->associate('\App\Models\Product');
        session()->flash('success_message', 'Items added in Cart');
        return redirect()->route('cart.index');
    }
4. Now in shopcomponent blade file, in Add To Cart a link add the following code wire code
 
<a aria-label="Add To Cart" class="action-btn hover-up" href="#" wire:click.prevent="store('{{$product->id}}', '{{$product->name}}', '{{$product->regular_price}}')"><i class="fi-rs-shopping-bag-add"></i></a>
5. Now in cart-component blade file 
in the table after <tbody> start write the following code
 @if (Cart::count()>0)
    <tr>
     <td class="image product-thumbnail"><img src="{{asset('assets/imgs/shop/product-1-2.jpg')}}" alt="#">
       </td>
     <td class="product-des product-name">
       <h5 class="product-name"><a href="product-details.html">J.Crew Mercantile Women's Short-Sleeve</a></h5>
       <p class="font-xs">Maboriosam in a tonto nesciung eget<br> distingy magndapibus </p>
      </td>
        <td class="price" data-title="Price"><span>$65.00 </span>
      </td>
      <td class="text-center" data-title="Stock">
        <div class="detail-qty border radius  m-auto">
         <a href="#" class="qty-down"><i class="fi-rs-angle-small-down"></i></a>
          <span class="qty-val">1</span>
         <a href="#" class="qty-up"><i class="fi-rs-angle-small-up"></i></a>
        </div>
      </td>
        
	  <td class="text-right" data-title="Cart">
         <span>$65.00 </span>
           </td>
           <td class="action" data-title="Remove"><a href="#" class="text-muted"><i class="fi-rs-trash"></i></a></td>
           </tr>
          @else
           <p>No Item In Cart</p>
         @endif

6. Now use following items to show cart items
  @foreach (Cart::content() as $item)
	<tr>
     <td class="image product-thumbnail"><img src="{{asset('assets/imgs/shop/product-')}}{{$item->model->id}}-1.jpg" alt="#"></td>
      <td class="product-des product-name">
       <h5 class="product-name"><a href="product-details.html">{{$item->model->name}}</a></h5>
      </td>
       <td class="price" data-title="Price"><span>${{$item->model->regular_price}} </span></td>
         <td class="text-center" data-title="Stock">
           <div class="detail-qty border radius  m-auto">
            <a href="#" class="qty-down"><i class="fi-rs-angle-small-down"></i></a>
            <span class="qty-val">1</span>
           <a href="#" class="qty-up"><i class="fi-rs-angle-small-up"></i></a>
         </div>
         </td>
        <td class="text-right" data-title="Cart">
         <span>${{$item->subtotal}} </span>
        </td>
         <td class="action" data-title="Remove"><a href="#" class="text-muted"><i class="fi-rs-trash"></i></a></td>
          </tr>
@endforeach
7. Now in cart totals
 <div class="table-responsive">
   <table class="table">
   <tbody>
      <tr>
       <td class="cart_total_label">Cart Subtotal</td>
       <td class="cart_total_amount"><span class="font-lg fw-900 text-brand">${{Cart::subtotal()}}</span></td>
      </tr>
      <tr>
       <td class="cart_total_label">Tax</td>
        <td class="cart_total_amount"><span class="font-lg fw-900 text-brand">${{Cart::tax()}}</span></td>
       </tr>
        <tr>
       <td class="cart_total_label">Shipping</td>
       <td class="cart_total_amount"> <i class="ti-gift mr-5"></i> Free Shipping</td>
       </tr>
        <tr>
 <td class="cart_total_label">Total</td>
 <td class="cart_total_amount"><strong><span class="font-xl fw-900 text-brand">${{Cart::total()}}</span></strong></td>
  </tr>
 </tbody>
 </table>
 </div>
after  @foreach ($products as $product)
	@endforeach
use:

{{$products->onEachSide(1)->links('pagination::bootstrap-4')}}
use Livewire\withPagination;
then in component main function write
 use withPagination;
    public function render()
    {
        $products = Product::paginate(12);
        return view('livewire.shop-component', compact('products'));
    }
3. You can pic images from asset folders in blade file by using the following code
<img class="default-img" src="{{asset('assets/imgs/shop/product-')}}{{$product->id}}-1.jpg" alt="">
<img class="hover-img" src="{{asset('assets/imgs/shop/product-')}}{{$product->id}}-2.jpg" alt="">
1. First make a factory by using the following code 
php artisan make:factory CategoryFactory -model=Category
2. Go to the CategogyFatory file in factories folder and write the following code
 $category_name = $this->faker->unique()->words($nb=2, $asText = true);
        $slug = Str::slug($category_name, '-');
        return [
            'name' => $category_name,
            'slug' => $slug
        ];
3. You can use Str class as on top
  use Illuminate\Support\Str;
4. Now go to the DatabaseSeeder and write the following code in the run function
 \App\Models\Category::factory(6)->create();
5. use the following command
php artisan db:seed
6. You can make as many factories and call in the databaseseeder file and use the factories
Thanks!
1. git reset HEAD --hard
2. git clean -fdx
3. git status
4. git pull
rename the app.blade.php file if exists for temporary
1. composer require laravel/breeze --dev
2. php artisan breeze:install
Delete the new built app.blade.php file and change the name of the file file in step 1 to again app.blade.php
Now add the following code in users file migration after password
  $table->string('utype')->default('USR')->comment('ADM for admin and USR for User');
3. now run php artisan migrate
4. npm install
5. npm run build
6. Now we can change or use login/logout/Register routes routes available 

 @auth
    <ul>                                
      <li><i class="fi-rs-key"></i>  {{Auth::user()->name}}  / 
        <form method="POST" action="{{route('logout')}}">
          @csrf
          <a href="{{route('logout')}}" onclick="event.preventDefault(); 			    					this.closest('form').submit();">Logout</a>
        </form>
       </li>
    </ul>
 @else
     <ul>                                
       <li><i class="fi-rs-key"></i>
		  <a href="{{route('login')}}">Log In </a>  / <a href="{{route('register')}}">Sign Up</a>		</li>
     </ul>
 @endif

7. the make middleware for that
php artisan make:middleware AdminMiddleware
8. then open the the middle file in http/middleware
9. now add the following code inhandle function

if (Auth::user()->utype === 'ADM') {
   return $next($request);
 }
 else{
 session()->flush();
 return redirect()->route('login');
 }
10. Use the following code in the header of middleware file to use auth
use Illuminate\Support\Facades\Auth;
11. Now open kernel.php file in http folder and add the following code in routemiddleware
'authadmin' => \App\Http\Middleware\AdminMiddleware::class,
  12. Now open the file routeservice provider in providers folder and delete the dashboard word in the line no 20 HOME
13. Now make two componnts use the following commands
php artisan make:livewire Admin/AdminDashboardComponent
php artisan make:livewire User/UserDashboardComponent
14. Now use the following code in web.php to use middleware in your project
Route::middleware(['auth'])->group(function(){
    Route::get('/user/dashboard', UserDashboardComponent::class)->name('user.dashboard');
});

Route::middleware(['auth', 'authadmin'])->group(function(){
    Route::get('/admin/dashboard', AdminDashboardComponent::class)->name('admin.dashboard');
});
1. first of all install livewire
composer require livewire/livewire
2. make livewire component
php artisan make:livewire HomeComponent
3. Make a folder in views named with layouts
4. then make file app.blade.php
5. Then write {{$slot}} where you want to render your livewire component
6. then write this code right before closing of head tag
  @livewireStyles
6. then write this code right before closing of head tag
  @livewireStyles
7. then write this code right before closing of body tag
  @livewireScripts
In laravel 9:
Command No 1 in controller:
return redirect()->route('category.index')->with('success', 'Record Entered Successfully');

then in blade
 @if (Session::has('success'))
      <div class="alert alert-success">
        {{Session::get('success')}}
      </div>
@endif
//Custom Validation 

$validated = Validator::make($data, [
                    'username' => 'required|unique:wbx_pos_merchant_terminals', // note the email field
                    'email' => 'required|unique:wbx_pos_merchant_terminals', // note the email field
                ]);
                return json_encode(
                    [
                        'error' => true,
                        'messages'=>$validated->errors()->all()
                    ]
                );
1. add the following code in laravel migrations to set foreign key
$table->unsignedBigInteger('customer_id');
$table->foreign('customer_id')->references('id')->on('customers');
or if you want to delete the foreign id data also
$table->foreign('customer_id')->references('id')->on('customers')->onDelete('cascade');
here 'customers' is the table of id here we are considering as foreign id
2. Now in the customer model as the following function
public function orders(){
        return $this->hasMany(Order::class, 'customer_id');
    }
3. In the order model add the following function
public function customer(){
        return $this->belongsTo(Customer::class, 'customer_id', 'id');
    }
1. Go to official link
https://spatie.be/docs/laravel-backup/v8/installation-and-setup
of spatie-backup and copy and run the following command [composer require spatie/laravel-backup]
2. Then copy and run the following command from the same link
[php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider"]
3. Now you can include or exclude any file from backup in the config/backup.php file
4. Now in database.php file go to 'mysql' code group and add the following line of code after 'engine' => null,
  the code to add::
   'dump' => [
                'dump_binary_path' => 'C:/xampp/mysql/bin/',
            ],
5. Now in terminal run the following command [php artisan backup:run]
6. Now check the storage folder for your backup zipped file
7. Enjoy backup thanks
1. First install laravel as usual
2. the cd/enter to your project
3. now run the command [npm i vue@next vue-loader@next] to install vue into your project
4. now install vue plugin run the command [npm i @vitejs/plugin-vue]
5. if it came npm errors the youcan install specified version of vitreplugin by typing
e.g[npm i @vitejs/plugin-vue@3.0.x]
6. now open vite.config.js file and add some code as follows
add this line at headings import vue from "@vitejs/plugin-vue";
7. then put a coma after laravel code and add the following code 
vue({
            template: {
                transformAssetUrls: {
                    base: null,
                    includeAbsolute: false,
                }
            }
        })
8. open the blade main or welcome file and make a div in the body with id 'app'
9. now go to the resources/js folder and make a file named welcome.vue and type the follwing code in it and save 
  <template>
    <h1>welcome page frm vue js</h1>
</template>
10. now open app.js file in resources/js folder and remove the existing code. Then type the following code
import {createApp} from "vue";
import welcome from './welcome.vue';

createApp(welcome).mount('#app');
11. No open welcome.blade file and add the following code in head section
@vite(['resources/js/app.js','resources/css/app.css'])
12. Hurrah!! now enjoy laravel with vue..
1. open your laravel application as normal routine in chrome browser
2. Now click on three dots at top right of browser 
3. Then click on more tools option
4. Then click on create shortcut
5. Tick the option here that is open as window.
6. Now change the shortcut image with your own image
7. convert png/jpg etc image to .ico image
8. enjoy the laravel app as your desktop application. Thanks!
1. Make a file named index.php in the parent application folder
2. Point this file to the index.php file exits in the public folder by writing this code in that file 
  <?php
 	require_once __DIR__.'/public/index.php';
3. copy .htaccess file from public folder to parent application folder
4. Now change all links and script libraries in layoutfiles with public at start of the href link and also with script src.
5. Now enjoy you have no need to use php artisan serve
1. Right click on xampp control and click run as administrator
2. click on config button at top right corner of xampp and tick on Apache and mysql then tick on start control panel minimized
3. Then create a short cut of xampp-control exe file in c drive
4. Then type run at task bar the in RUN type shell:startup then paste the short to that startup folder
5. and thats it now you can restart your computer to check the auto ON functionality.
Thanks!
 ->columns([
                Tables\Columns\TextColumn::make('name'),
                Tables\Columns\TextColumn::make('urls')
                    ->label('No. URLs')
                    ->getStateUsing(function (Site $record) {
                        return count($record->urls);
                    }),
            ])
Forms\Components\TextInput::make('url')
  ->label('URL')
  ->url()
  ->required(),
  ])
    ->createItemButtonLabel('Add URL'
$posts = Post::whereDate('created_at', Carbon::today())->get();
// show
return Responder::respondValid(
    [
        'Model' => Model::with($relationships)->find($consultTopicId)
    ]
);

// index
return Responder::respondValid(
  	[
      	'MemberProviderConsults' => ConsultLogResource::collection(
        	MemberProviderConsult::with(
            	$this->relations
            )->where('columns', $filter)->orderBy('id', 'desc')->get()
      )
  ]
);

// Store
 $models = Model::create(
    [
        'name' => $request->input('name')
        'description' => $request->input('description', null)
    ]
);

$model->BelongsToManyRelation()->sync($request->input('relatedModelIds'));

return Responder::respondValid(
    [
        'model' => $model
    ]
);

// Update
$model = Model::find($modelId);

if ($request->input('name')) {
    $model->update(
        [
            'name' => $request->input('name')
            'description' => $request->input('description', null)
        ]
    );
}
$model->belongsToManyRelation()->sync($request->input('relatedModelIds'));
$model->questions()->sync($request->input('otherRelatedModelIds'));

$this->updateRequiredQuestions($request, $model->id);

return Responder::respondValid(
    [
        'model' => $model->refresh()->load($this->relations)
    ]
);
After the Ethereum Merge Event, Ethereum has become more admired in the crypto industry. Meantime, the price of ethereum has skyrocketed. Do you wanna create an ethereum standard token? https://bit.ly/3TlCuwx 

Being the trusted Ethereum Token Development Company that rendering excellent Token Development Services on multiple ethereum standards such as ERC20, ERC1155, ERC223, ERC721, ERC777, ERC827, ERC 998, and ERC1400 to enhance your tokenomics business and platform.

For Instant Connect, 
Whatsapp +91 9384587998 || Telegram @maticzofficial

1.go to htdocs folder and open git bash
2. git clone "url taken from remote github link"
3. cd projectName
4. composer update / composer install
5. make database name it with projectname or other
6. you can do npm install if required
7. then make a copy of .env file by using this command
8. cp .env.example .env
9. php artisan key:generate
10. php artisan migrate --seed
--------Include this in seeder file-------
use Illuminate\Support\Facades\Hash;
$user->password = Hash::make('12345');
----------Terminal Command------------------------
php artisan make:seeder BookSeeder
----------BookSeeder Code---------------------------
  use Faker\Factory as Faker;
----------Public function run() code------------------
 $faker = Faker::create();
       for ($i=0; $i < 100; $i++) { 
            $book = new Book;
            $book->book_name = $faker->name;
            $book->book_author = $faker->city;
            $book->save();
        }
----------Database Seeder code public function run()---------------
   $this->call([
            BookSeeder::class
        ]);
------------------php artisan code--------------------------------
php artisan db:seed
---------write it in head section in blade template-----------------
<meta name="csrf-token" content="{{csrf_token()}}"> 
  ----------do not use slim version of J Query---------------
    --------Use this before document ready in script tag--------
    <script>
          $.ajaxSetup({
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    }
                });
    </script>
------------------then------------------------------------
 <script>
        $(document).ready(function(){
            $('#country').change(function(){
                var country_id = $(this).val();
                $('#city').html('<option value="">Select City</option>');
                
                $.ajax({
                    url: '/getState/'+country_id,
                    type:'post',
                    success: function(result){
                        $('#state').html(result);
                    }
                });
            });

            $('#state').change(function(){
                var state_id = $(this).val();

              
                
                $.ajax({
                    url: '/getCity/'+state_id,
                    type:'post',
                    success: function(result){
                        $('#city').html(result);
                    }
                });
            });
        });
    </script>
--------------------------web.php code--------------------------
Route::post('/getState/{id}', [PlaceController::class, 'getState']);
Route::post('/getCity/{id}', [PlaceController::class, 'getCity']);
-------------------------Controller Code -----------------------------
  public function getState($country_id){
        $states = State::where('country_id', $country_id)->get();
        $html = '';
        foreach($states as $state){
            $html .='<option value="'.$state->id.'">'.$state->state_name.'</option>';
        }
        echo $html;
    }

    public function getCity($state_id){
        $cities = City::where('state_id', $state_id)->get();
        $html = '';
        foreach($cities as $city){
            $html .='<option value="'.$city->id.'">'.$city->city_name.'</option>';
        }
        echo $html;
    }
<?php

namespace App\Traits;

trait ResponseApi
{
    public function coreResponse($message, $data = null, $statusCode, $isSuccess = true)
    {
        if (!$message) {
            return response()->json(['message' => 'Message is required'], 500);
        }

        if ($isSuccess) {
            return response()->json([
                'message' => $message,
                'error' => false,
                'code' => $statusCode,
                'results' => $data
            ], $statusCode);
        } else {
            return response()->json([
                'message' => $message,
                'error' => true,
                'code' => $statusCode,
            ], $statusCode);
        }
    }

    public function success($message, $data, $statusCode = 200)
    {
        return $this->coreResponse($message, $data, $statusCode);
    }

    public function error($message, $statusCode = 500)
    {
        return $this->coreResponse($message, null, $statusCode, false);
    }
}
// In the controller
throw Illuminate\Validation\ValidationException::withMessages([
    "one_thing" => ["Validation Message #1"], 
    "another_thing" => ['Validation Message #2']
]);
$promises = Http::pool(function (Pool $pool) use ($schoolId, $filter, $batch, $studentGroupId) {
            $pool->as('schoolStaff')->withToken(Auth::user()->token())
                ->get(Api::schoolStaff()->index($schoolId, [], true), $filter);
            $pool->as('schoolBatchStudentGroup')->withToken(Auth::user()->token())
                ->get(Api::schoolBatchStudentGroup()->detail($schoolId, $batch, $studentGroupId, true));
        });

        $staffDatas = json_decode($promises['schoolStaff']->getBody(), true)['data'] ?? [];
        $studentGroup = json_decode($promises['schoolBatchStudentGroup']->getBody(), true)['data'] ?? [];
#!/bin/sh
set -e
 
echo "Deploying application ..."
 
# Enter maintenance mode
(php artisan down --message 'The app is being (quickly!) updated. Please try again in a minute.') || true
    # Update codebase
    git fetch origin deploy
    git reset --hard origin/deploy
 
    # Install dependencies based on lock file
    composer install --no-interaction --prefer-dist --optimize-autoloader
 
    # Migrate database
    php artisan migrate --force
 
    # Note: If you're using queue workers, this is the place to restart them.
    # ...
 
    # Clear cache
    php artisan optimize
 
    # Reload PHP to update opcache
    echo "" | sudo -S service php7.4-fpm reload
# Exit maintenance mode
php artisan up
 
echo "Application deployed!"
server {
    listen 80;
    listen [::]:80;
    server_name example.com;
    root /srv/example.com/public;
 
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";
 
    index index.php;
 
    charset utf-8;
 
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
 
    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }
 
    error_page 404 /index.php;
 
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }
 
    location ~ /\.(?!well-known).* {
        deny all;
    }
}
Go to directory laravel/bootstrap/cache and delete config.php file.


How did I solve this issue? After running those commands and not getting the solution.


composer dump-autoload
composer install
php artisan cache:clear
php artisan config:clear
php artisan optimize
php artisan clear-compiled
composer create-project laravel/laravel test_laravel
public function handle()
{
     $datas = Model::all();

     $bar = $this->output->createProgressBar($datas->count());

     $datas->each(function ($data) use ($bar) {
         try {
             // do something
         } catch (Exception $e) {
             $this->error('Error');
         }

         $bar->advance();
     });
}
// will add this code in web.php page 
Route::get("/mail",function(){
    Mail::raw("thank you", function($messsage){
        $messsage->to("name@gmail.com")->subject("contact with me");
    });
});

// will add this code at env file 
MAIL_MAILER=log

// to see the result you should go to www.myapp.com/mail then go to laravel.log file you will find the result there 
public function boot()
{
    User::observe(UserObserver::class);
}
Next, add an Observer class like so:

class UserObserver
{
    public function deleting(User $user)
    {
         $user->photos()->delete();
    }
}
composer require itsgoingd/clockwork
- in terminal: brew services start mysql
- alternatively, use DBngin

- open database front-end to create MySQL DB
    - Name: dbName
    - Host: 127.0.0.1
    - Username: root
    - Password is empty
    
- rename wp-config-sample.php to wp-config.php and update db variables
    
Use this info to complete Wordpress setup
in .env change APP_URL to 

APP_URL=http://localhost:port 
$this->assertSame('FooBar', Str::reverse('raBooF'));
$this->assertSame('Teniszütő', Str::reverse('őtüzsineT'));
$this->assertSame('❤MultiByte☆', Str::reverse('☆etyBitluM❤'));
//original
$dotted = [
    'user.name' => 'foo',
    'user.occupation' => 'bar',
];
 
// Converts it back to the original form
Arr::undot($dotted);

// Results in...
$resultArray = [
    'user' => [
        'name' => 'foo',
        'occupation' => 'bar',
    ]
];
$original = [
    'user' => [
        'name' => 'foo',
        'occupation' => 'bar',
    ]
];
 
$dotted = Arr::dot($original);
 
// Results in...
$dotted = [
    'user.name' => 'foo',
    'user.occupation' => 'bar',
];
Event::fakeExcept([
    NonImportantEvent::class,
    'non-fake-event',
]);
$schedule->command('model:prune', [
    '--exclude' => [Test::class, Example::class],
])->daily();
export $(sudo cat /opt/elasticbeanstalk/deployment/env) && sudo -E -u webapp php artisan tinker
php artisan cache:clear
php artisan route:clear
php artisan config:clear 
php artisan view:clear 
Update your /app/Providers/AppServiceProvider.php to contain:

use Illuminate\Support\Facades\Schema;

/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    Schema::defaultStringLength(191);
}
// in terminal, php artisan to create middleware
php artisan make:middleware VerifyIsAdmin

// in VerifyIsAdmin middleware file
public function handle(Request $request, Closure $next)
{
  if (!auth()->user()->isAdmin()) {
    return redirect()->back();
  }
  return $next($request);
}

// must register in kernel.php
protected $routeMiddleware = [
  'auth' => \App\Http\Middleware\Authenticate::class,
  'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
  'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
  'can' => \Illuminate\Auth\Middleware\Authorize::class,
  'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
  'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
  'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
  'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
  'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
  'verifyCategoryCount' => VerifyCategoriesCount::class,
  'admin' => VerifyIsAdmin::class,
];

// use in Route to ensure user is authenticated and admin
Route::middleware(['auth', 'admin'])->group(function () {
    Route::get('users', [UsersController::class, 'index'])->name('users.index');
});
// class ExampleRequest 
public function response(array $errors): RedirectResponse
{
  return Redirect::back()->withErrors($errors)->withInput();
}
<!-- form.blade.php -->
<div class="form-group col-md-6 mb-3">
   <label for="contact_lastname">Nom <span class="text-danger">*</span></label>
   <input type="text"
          class="form-control @if($errors->has('contact_lastname')) is-invalid @endif"
          id="contact_lastname" name="contact_lastname"
          aria-describedby="validation_contact_lastname">
   @if($errors->has('contact_lastname'))
   <div id="validation_contact_lastname" class="invalid-feedback">
     {{$errors->first('contact_lastname') }}
   </div>
   @endif
</div>

<!-- ContactsController.php -->
$request->validate([
   'contact_lastname' => 'required'
]);
composer require laravel/sail --dev
php artisan sail:install
./vendor/bin/sail up
// Create 5 documents
$documents = Document::factory()->count(5)->make();

// Create contact
$contact->documents()->saveMany($documents);
/**
     * Query Public schema and return any req'd settings.
     */
    public static function getSettingsFromPublic()
    {
        if (Schema::connection('public')->hasTable('pubs')) {
            DB::table('public.pubs_settings')->select('ps.id, LOWER(ps.name) AS name, ps.description, ps.value, ps.resolve_include_path, ps.set_as_null, psc.name AS category, cst.name AS type, cse.name AS element')->join('components_settings_types_elements cste', 'cste.id', 'ps.components_settings_types_elements_id')->where('psc.name', 'css')->orderBy('ps.name', 'ASC')->get();
            $statement = "SELECT ps.id, LOWER(ps.name) AS name, ps.description, ps.value, ps.resolve_include_path, ps.set_as_null, psc.name AS category, cst.name AS type, cse.name AS element FROM pubs_settings ps JOIN pubs_settings_categories psc ON (psc.id = ps.pubs_settings_categories_id) JOIN components_settings_types_elements cste ON (cste.id = ps.components_settings_types_elements_id) JOIN components_settings_types cst ON (cst.id = cste.components_settings_types_id) JOIN components_settings_elements cse ON (cse.id = cste.components_settings_elements_id) WHERE psc.name = 'css' ORDER BY ps.name ASC";
            $data = DB::connection('public')->statement($statement);
        }
    }
$response = $response->withHeader('x-joey-test', 'myvalue');

return $response->withStatus(404)->getBody()->write('not found');
return $response->getBody()->write('hello world');
// convention is to make table name singular and in alphabetical order
php artisan make:migration create_post_tag_table

// create_post_tag_table.php
// if 1 post has 5 tags, then 5 records will exist with same post_id and different tag_ids
public function up()
{
  Schema::create('post_tag', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->integer('post_id');
    $table->integer('tag_id');
    $table->timestamps();
  });
}

// Post.php
// define relationship in Post model
public function tags()
{
  return $this->belongsToMany(Tag::class);
}
// php artisan make:seeder NameOfTheSeeder

<?php

namespace Database\Seeders;

use App\Models\ModelName;
use Illuminate\Database\Seeder;

class ModelNameSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        ModelName::factory()->count(50)->create();
    }
}
/**
 * Carbon example for january 2021 
 */

// first day of month (2021-01-01 00:00:00)
Carbon::now()->firstOfMonth()->startOfDay()

// first day of month in timestamp (1609459200)
Carbon::now()->firstOfMonth()->startOfDay()->timestamp

// last day of month (2021-01-31 23:59:59)
Carbon::now()->lastOfMonth()->endOfDay()

// last day of month in timestamp (1640995199)
Carbon::now()->lastOfMonth()->endOfDay()->timestamp

/**
 * Carbon example for january 1, 2021 
 */

// start of day in date (2021-01-01 00:00:00)
Carbon::now()->startOfDay()
 
// start of day in timestamp (1609459200)
Carbon::now()->startOfDay()->timestamp
 
// end of day in date (2021-01-01 23:59:59)
Carbon::now()->endOfDay()
 
// end of day in timestamp (1609545599)
Carbon::now()->endOfDay()->timestamp
Route::middelware(['auth'])->group(function (){

    Route::get('/', function () {
        return view('welcome');
    });

    Route::get('/dashboard', function (){
        return view('dashboard');
    })->name('dashboard');

});
Route::patch('aluminio/{id}', 'AluminioController@update')->name('aluminio.update');
$tasks = Tasks::find(1);
$newTask = $tasks->replicate();
$newTask->save();
//Multiple relationships:
$books = Book::with('author', 'publisher')->get();

//Nested relationships:
$books = Book::with('author.contacts')->get();
<!-- use enctype -->
<form  action="/route" method="POST" enctype="multipart/form-data">
class="{{ Request::is('products.index') ? 'active' : '' }}"
// url : https://www.example.com/param1/param2/param3
$request()->segment(3); // param3
// config/app.php
'locale' => 'fr',
'fallback_locale' => 'fr',
// replace get()
$products = Product::where('active', 1)->get();

// by paginate()
$products = Product::where('active', 1)->paginate(10);
// config\database.php
'connections' => [
    'mysql' => [
      (...)
      'strict' => true,
    ],
],
$this->validate($request, [
	"field_nullable" => "nullable"
]
/**
* Artisan Command
*/

php artisan make:request RequestName

/**
* Controller Code
*/
// inject filepath to custom request
use App\Http\Requests\RequestName;

// inject custom request as $request
// $request knows about validation and will automatically validate
public function store(RequestName $request)
    {
        Category::create([
            'name' => $request->name
        ]);

        session()->flash('success', 'Category Successfully Created');

        return redirect(route('categories.index'));
    }
    
/**
* Request File
*/
class CreateCategoryRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
    // this is where validation rules are set
        return [
            'name' => 'required|unique:categories'
        ];
    }
}
if (str_contains(url()->current(), '/api')) {

            $finalProperty = [];
            $properties = PropertyListing::orderBy('id', 'DESC')->get(["id","user_id","listing_for","images","address","price","property_type","furnishing_status","facilities"]);
            foreach ($properties as $key => $property){
                // $finalImage['id'] = $property->id;
                // $finalImage['user_id'] = $property->user_id;
                // $finalImage['listing_for'] = $property->listing_for;
                $img_array = explode(',',$property->images);

                $properties[$key]->images = $img_array;

            }
         
            return response()->json(['properties' => $properties, 'success' => 200]);
            
        } else {
            $sliderImages = PropertyListing::all();
            return view('admin.imageslider.index', compact('sliderImages'));
        }
\Log::info(print_r($siteImageUrl, true));
php artisan migrate:refresh --path=/database/migrations/my_migration.php
NotificationFactory::new()->create();



use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Notifications\DatabaseNotification;
use Illuminate\Support\Str;

class NotificationFactory extends Factory
{
    protected $model = DatabaseNotification::class;

    public function definition()
    {
        return [
            'id' => Str::uuid()->toString(),
            'type' => 'App\Notifications\ThreadSubscription',
            'notifiable_id' => function() {
                return auth()->id() ?? User::factory()->create();
            },
            'notifiable_type' => 'App\Models\User',
            'data' => ['message' => 'text']
        ];
    }
}
* Start the VM
	- vagrant up
	- vagrant ssh
* Shutdown and remove everything in memory
	- vagrant halt
* Close the VM for later use
	- vagrant suspend
	- vagrant resume
* Changed the homestead.yaml file?
	- vagrant provision
composer create-project "laravel/laravel=5.1.*" sampleproject
// sending a massage to blade from controller
return redirect()->route('add_item')->with('message', "Category Created Successfully");


//Checking for a message from the blade 
  @if(session()->has('message'))
    <div class="alert alert-success">
        {{ session()->get('message') }}
    </div>
@endif
$entities = $user->entities;
$entityIds = $entities->map( function($entity) {
    return [$entity['id']];
});
Entity::whereIn('id', $entityIds)->deleted();
php artisan cache:clear
chmod -R 777 storage/
composer dump-autoload
Route::group(['prefix' => '/user'], function () {
    Route::get('/profile', function(){
        return 'Profile';
    });

    Route::get('/password', function(){
        return 'Password';
    });
});
$validatedData = $request->validate([
    'name' => 'required',
    'gender' => 'required',
    'country' => 'required',
    'bod'=>'required',
    'description'=>'required',
]);

Profile::where('user_id',$user_id)->fill([
        'name'=>'name',
        'gender'=>'gender',
        'country'=>'country',
        'bod'=>'bod',
        'description'=>'description',
    ])->save();
Hello, As I read in your description that your company has many php- laravel, javascript projects, I am very interested in working with you. As you can see my profile, I have worked in core PHP, php and wordpress and javascript many times. I can work in this domain.
I know MVCs very well and have experience with them. I have worked with MVC CRUD, routing, integrating frontend technologies like vue.js and angular.js with the MVCs.
I have spent time in Integrating payment gateways in php and laravel.
I am also quiet good in architecturing databases like MySQL.
So overall I feel I will be a great fit t your system if selected once for a project.
If any thing is new for me that has to be implemented in the project then I find it to be a great opportunity of learning and implementation. So you can trust me and keep me as your working partner. You wil find me as a basic need of your development team after I have spent some time working with youl.
I will be waiting for your response.
Thank you.
Kind Regards.
public function update(Request $request, $id)
    {
        $this->validate($request, [
            'name' => 'required|unique:categories',
        ]);

        $category = Table::findOrFail($id);
        $category->name = $request->name;
        $category->save();
        return redirect()->route('management.table.home')->with('message', "Table Edited Successfully");
    }
   User::create([
           'name' => $request->name,
           'username' => $request->username,
           'email' => $request->email,
           'password' => Hash::make($request->password),

        ]);
<form action="{{ route('posts.likes', $post->id) }}" type="submit" method='post' >
                  @csrf
                  @method('delete')
                <button  type="submit" class="btn btn-primary btn-sm">Dislike</button>
              </form>

//route
Route::delete('/posts/{id}/likes', [PostLikeController::class, 'destroy'])->name('posts.likes');
// In post model are we are checking whether user has liked it:
// contains is a collection method which allows to look at the inside of the collection
// with collectiong you are looking at a particular key (user_id), and checking if the $user->id is within the collection
// then it will return a true or false
 
// POST MODEL: 
public function likedBy(User $user){
      return $this->likes->contains('user_id', $user->id);
    }

//POSTLIKECONTROLLER
 public function store($id, Request $request){
// this is activating when you press the submit button for like

        $this->middleware(['auth']);


        $post = Post::find($id);

        if ($post->likedBy($request->user())){
            return back(); 
        }
        
        $post->likes()->create([
            'user_id' => $request->user()->id,
        ]);
        return back();




 {{ Str::plural('like', $post->likes->count()) }}
public function store(Request $request)
    {
        $this->validate($request, [
            'name' => 'required|unique:categories',
        ]);

        Category::create([
            'name' => $request->name,
        ]);
Route::get('/',closure)
<button type="submit" id="customers_filter" onclick="checkWhetherTheTableContainsSearchResults()"
                                class="btn filter-button d-inline-block ml-3">
                                Filter
                            </button>
                            
<input id="search-hidden-input" hidden name="searchValue">

<script>
function checkWhetherTheTableContainsSearchResults() {
        let search = location.search.substring(1)
            searchInputElement = document.getElementById('search-hidden-input');
        
        if(search != '') {
            searchInputElement.setAttribute('value', search);
        }
    }
</script>
    
// If the filter is to work on search results, the original search parameter has to be passed into the request array.
        // Thus, the request array will return more than one parameter 
        // AND
        // one of the parameters will be searchValue
        // WHICH
        // will contain the entire search parameter (key + value)

        if ((count($request->all()) > 1) && (isset($request->searchValue))) {
            if (strpos($request->searchValue, '=')) {
                $string = $request->searchValue;
                $array = explode('=', $string);
                $request->searchValue = $array[1];
            }
        }
"repositories": {
        "webdevmatics/jetstream" : {
            "type": "path",
            "url": "C:\\laragon\\www\\codegenerator\\packages/webdevmatics/jetstream"
        }
    }
star

Thu Feb 02 2023 15:11:21 GMT+0000 (UTC)

#php #laravel #command
star

Fri Jan 06 2023 04:29:42 GMT+0000 (UTC)

#laravel #ajax
star

Wed Jan 04 2023 07:11:52 GMT+0000 (UTC)

#laravel #ajax
star

Wed Jan 04 2023 06:57:31 GMT+0000 (UTC)

#laravel #ajax
star

Wed Jan 04 2023 06:51:38 GMT+0000 (UTC)

#laravel #ajax
star

Tue Jan 03 2023 07:18:36 GMT+0000 (UTC)

#laravel #ajax
star

Mon Jan 02 2023 10:15:44 GMT+0000 (UTC)

#laravel #ajax
star

Fri Dec 30 2022 06:57:11 GMT+0000 (UTC)

#laravel #ajax
star

Wed Dec 28 2022 04:15:12 GMT+0000 (UTC)

#php #laravel
star

Thu Dec 22 2022 12:27:38 GMT+0000 (UTC)

#laravel #ajax
star

Thu Dec 22 2022 11:15:52 GMT+0000 (UTC) https://stackoverflow.com/questions/48533921/validation-rule-unique-requires-at-least-1-parameters

#php #laravel
star

Thu Dec 15 2022 02:43:24 GMT+0000 (UTC)

#laravel #ajax
star

Tue Dec 13 2022 07:23:56 GMT+0000 (UTC) Install Vue 3 In Laravel 9 With Vite | Laravel Vite With Vue 3 | Vite Laravel Vue 3 | #1 HINDI

#laravel #ajax
star

Sun Dec 11 2022 16:08:23 GMT+0000 (UTC)

#laravel #ajax
star

Sun Dec 11 2022 15:50:54 GMT+0000 (UTC)

#laravel #ajax
star

Fri Nov 25 2022 21:07:59 GMT+0000 (UTC) https://github.dev/ryangjchandler/uptime-checker

#laravel
star

Fri Nov 25 2022 21:04:19 GMT+0000 (UTC) https://github.dev/ryangjchandler/uptime-checker

#laravel
star

Mon Nov 21 2022 20:24:51 GMT+0000 (UTC) https://stackoverflow.com/questions/33247908/get-only-records-created-today-in-laravel

#laravel
star

Fri Oct 28 2022 12:53:53 GMT+0000 (UTC) controller-logic

#php #controller #laravel
star

Wed Oct 19 2022 10:25:51 GMT+0000 (UTC) https://maticz.com/how-to-create-nft-marketplace

#javascript #java #laravel #angular
star

Wed Oct 19 2022 10:19:52 GMT+0000 (UTC) https://bit.ly/3GLa8p1

#javascript #java #php #laravel #angular #nodejs
star

Wed Oct 19 2022 10:16:04 GMT+0000 (UTC) https://maticz.com/ethereum-token-development

#java #javascript #php #laravel
star

Wed Oct 19 2022 10:11:54 GMT+0000 (UTC) https://bit.ly/3RN2YXJ

#java #javascript #php #laravel
star

Tue Oct 18 2022 10:28:17 GMT+0000 (UTC)

#laravel #ajax
star

Tue Oct 11 2022 07:41:46 GMT+0000 (UTC)

#laravel #ajax
star

Sat Oct 08 2022 16:05:01 GMT+0000 (UTC)

#laravel #ajax
star

Fri Sep 30 2022 05:06:47 GMT+0000 (UTC) https://larainfo.com/blogs/laravel-8-authentication-with-laravel-ui

#laravel
star

Fri Sep 30 2022 02:56:21 GMT+0000 (UTC) https://www.educba.com/laravel-commands/

#laravel
star

Thu Sep 29 2022 18:35:24 GMT+0000 (UTC) https://codesource.io/complete-laravel-8-image-upload-tutorial-with-example/

#laravel
star

Thu Sep 15 2022 05:44:35 GMT+0000 (UTC) https://www.hivelance.com/binance-clone-script

#javascript #php #nodejs #laravel
star

Tue Aug 30 2022 12:30:23 GMT+0000 (UTC)

#laravel
star

Thu Aug 18 2022 13:21:26 GMT+0000 (UTC)

#laravel
star

Fri Jul 22 2022 03:40:39 GMT+0000 (UTC)

#php #laravel
star

Tue Jun 21 2022 05:01:33 GMT+0000 (UTC) https://laravel.com/docs/9.x/deployment

#php #laravel #nginx
star

Sat Jun 18 2022 06:21:50 GMT+0000 (UTC) https://stackoverflow.com/questions/59595863/file-put-contentsc-xampp-htdocs-instant-storage-framework-sessions-ff-failed

#php #laravel
star

Thu Jun 16 2022 12:24:06 GMT+0000 (UTC) https://stackoverflow.com/questions/18862160/composer-laravel-create-project

#php #laravel
star

Sat May 28 2022 09:49:21 GMT+0000 (UTC)

#laravel
star

Sun Apr 24 2022 03:22:34 GMT+0000 (UTC) Home

#php #laravel
star

Wed Mar 23 2022 12:27:31 GMT+0000 (UTC) undefined

#laravel #migrate
star

Wed Mar 23 2022 03:02:28 GMT+0000 (UTC) https://gist.github.com/dev-jaskaranSingh/e209225626d7b1b18a89d41d4a6ecfed

#laravel #php
star

Tue Mar 08 2022 07:57:30 GMT+0000 (UTC) https://github.com/itsgoingd/clockwork

#laravel
star

Tue Mar 01 2022 15:42:38 GMT+0000 (UTC)

#php #laravel
star

Tue Feb 01 2022 08:49:51 GMT+0000 (UTC) https://stackoverflow.com/questions/59697588/laravel-voyager-not-showing-images

#laravel
star

Thu Dec 02 2021 08:07:22 GMT+0000 (UTC) https://laravel-news.com/laravel-8-74-0

#php #laravel
star

Thu Dec 02 2021 08:04:47 GMT+0000 (UTC) https://laravel-news.com/laravel-8-74-0

#php #laravel
star

Thu Dec 02 2021 08:00:24 GMT+0000 (UTC) https://laravel-news.com/laravel-8-74-0

#php #laravel
star

Thu Dec 02 2021 07:54:36 GMT+0000 (UTC) https://laravel-news.com/laravel-8-74-0

#php #laravel
star

Thu Dec 02 2021 07:50:26 GMT+0000 (UTC) https://laravel-news.com/laravel-8-74-0

#php #laravel
star

Thu Dec 02 2021 07:47:42 GMT+0000 (UTC) https://laravel-news.com/laravel-8-74-0

#php #laravel
star

Wed Nov 24 2021 19:03:48 GMT+0000 (UTC) https://stackoverflow.com/questions/61816556/laravel-artisan-tinker-from-amazon-linux-2-elastic-beanstalk

#php #elasticbeanstalk #laravel
star

Thu Nov 18 2021 20:18:27 GMT+0000 (UTC) https://stackoverflow.com/questions/42244541/laravel-migration-error-syntax-error-or-access-violation-1071-specified-key-wa

#php #laravel
star

Thu Nov 18 2021 02:32:53 GMT+0000 (UTC)

#php #laravel
star

Fri Oct 29 2021 04:36:51 GMT+0000 (UTC) https://laravel.com/docs/8.x/middleware

#php #laravel
star

Tue Oct 19 2021 15:45:06 GMT+0000 (UTC)

#laravel
star

Tue Oct 19 2021 14:30:52 GMT+0000 (UTC)

#laravel
star

Wed Oct 13 2021 21:32:30 GMT+0000 (UTC)

#laravel
star

Tue Oct 05 2021 20:40:04 GMT+0000 (UTC)

#laravel
star

Fri Sep 24 2021 17:36:04 GMT+0000 (UTC)

#php #laravel
star

Fri Jul 30 2021 00:28:21 GMT+0000 (UTC) https://laravel.com/docs/8.x/eloquent-relationships#many-to-many

#php #laravel
star

Thu Jun 24 2021 20:46:42 GMT+0000 (UTC)

#laravel
star

Thu Jun 17 2021 19:33:02 GMT+0000 (UTC)

#laravel
star

Fri Jun 11 2021 21:12:23 GMT+0000 (UTC) https://dev.to/jeromew90/how-use-sweetalert2-in-laravel-8-using-composer-jki

#laravel
star

Fri Jun 11 2021 21:12:02 GMT+0000 (UTC) https://dev.to/jeromew90/how-to-create-a-multilingual-project-in-laravel-internationalization-i18n-11ol

#laravel
star

Fri Jun 11 2021 21:03:44 GMT+0000 (UTC)

#laravel
star

Fri Jun 11 2021 20:56:52 GMT+0000 (UTC)

#php #laravel
star

Fri Jun 11 2021 20:54:44 GMT+0000 (UTC)

#php #laravel
star

Fri Jun 11 2021 20:53:36 GMT+0000 (UTC)

#php #laravel
star

Sun May 16 2021 17:42:10 GMT+0000 (UTC) https://laravel.com/docs/8.x/validation#form-request-validation

#laravel
star

Mon Apr 19 2021 06:15:12 GMT+0000 (UTC)

#laravel
star

Tue Apr 06 2021 20:22:31 GMT+0000 (UTC) https://www.google.com/search?q

#php #laravel
star

Tue Apr 06 2021 12:42:54 GMT+0000 (UTC) https://stackoverflow.com/questions/47151886/how-can-i-run-specific-migration-in-laravel

#laravel #php
star

Sat Mar 20 2021 06:03:45 GMT+0000 (UTC)

#commandline #laravel
star

Wed Mar 17 2021 08:33:26 GMT+0000 (UTC) https://qiita.com/revenue-hack/items/f90fa5a7d4352d0bbc3f

#laravel #php
star

Fri Mar 12 2021 12:42:08 GMT+0000 (UTC)

#laravel
star

Thu Mar 11 2021 06:41:43 GMT+0000 (UTC) https://laracasts.com/discuss/channels/eloquent/how-to-delete-multiple-records-using-laravel-eloquent

#laravel #php
star

Wed Mar 10 2021 19:39:41 GMT+0000 (UTC) https://es.stackoverflow.com/questions/177114/cómo-redirigir-a-un-usuario-según-su-rol-en-laravel

#rol #laravel
star

Tue Mar 09 2021 14:34:57 GMT+0000 (UTC) https://stackoverflow.com/questions/36460874/laravel-5-errorexception-failed-to-open-stream-permission-denied

#laravel
star

Fri Feb 26 2021 13:51:51 GMT+0000 (UTC)

#laravel
star

Thu Feb 18 2021 15:22:20 GMT+0000 (UTC) https://stackoverflow.com/questions/57985564/laravel5-8-the-get-method-is-not-supported-for-this-route-supported-methods-p

#php #save #laravel
star

Fri Jan 15 2021 13:28:09 GMT+0000 (UTC)

#php #laravel
star

Mon Jan 11 2021 19:39:41 GMT+0000 (UTC)

#laravel
star

Thu Dec 31 2020 11:35:22 GMT+0000 (UTC)

#laravel
star

Mon Dec 28 2020 13:06:02 GMT+0000 (UTC)

#laravel
star

Mon Dec 28 2020 10:39:10 GMT+0000 (UTC)

#laravel
star

Sun Dec 27 2020 11:56:53 GMT+0000 (UTC)

#laravel
star

Sun Dec 27 2020 08:06:01 GMT+0000 (UTC)

#laravel
star

Fri Dec 11 2020 14:49:35 GMT+0000 (UTC) https://www.hoclabs.com/2018/01/14/laravel-roles-y-permisos/

#roles #laravel
star

Tue Dec 01 2020 00:27:14 GMT+0000 (UTC)

#laravel
star

Thu Nov 26 2020 18:43:15 GMT+0000 (UTC) https://virtumedia.wordpress.com/2020/02/27/generar-documentos-pdf-en-laravel-que-incluyan-graficos/

#pdf #laravel
star

Tue Nov 10 2020 15:39:18 GMT+0000 (UTC) https://es.stackoverflow.com/questions/218143/envio-de-mail-con-archivo-adjunto-laravel

#email #laravel
star

Fri Oct 02 2020 03:24:40 GMT+0000 (UTC)

#php #laravel

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension