moukbel

moukbel

Member Since 5 Months Ago

Experience Points 4,260
Experience Level 1

740 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 16
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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.

16 Aug
2 days ago

moukbel left a reply on Upload/load Images In Shared Host?

@jlrdw

my public folder located here , including editing the path in index.php

/var/www/public_html/

and Laravel project is here :

/var/www/laravel/

i don't know why

            'root'   => public_path() . '/uploads',

refere to empty public folder inside here:

/var/www/laravel/public

moukbel left a reply on Upload/load Images In Shared Host?

thanks for help,

I have added a new disk to filesystems.php

 'public_uploads' => [
            'driver' => 'local',
            'root'   => public_path() . '/uploads',
            'visibility' => 'public',
        ],

and use it to store file:


$path=  $request->file('file')->storeAs( 'products', $fileNameToStore , 'public_uploads' );

or

Storage::disk('public_uploads')->put( 'products' ,  $request->file('file') );

work fine locally but nothing appears in a shared host, instead, it's storeing in the old public folder, not inside project not inside public_html,

if i changed the root to this it's locating the folder currently :

 'root'   => public_path() . '/../../public_html/uploads',

15 Aug
3 days ago

moukbel started a new conversation Upload/load Images In Shared Host?

hi, I knew its repeated question. create a symbolic link doesn't work in a shared host, so if I use this method to store file:

$path=  $request->file('file')->storeAs('products/',$fileNameToStore);

the files will stored in storage\app\public\products and i can't access it from public folder using: <img src="{{ asset(/storage/products/) }}''>

any help? thanks,

26 Jul
3 weeks ago

moukbel left a reply on Using Orwhere() Without Effecting The Previews Conditions

thanks, TYKUS its work perfectly,

i had to add $key this way to work

 ->where(function ($builder) use($key) {

    }

moukbel started a new conversation Using Orwhere() Without Effecting The Previews Conditions

hi,

i'm having table with 1000 records ;

1- im fetching by buyer_id then the results become 100;

2- then I'm using new where() to filter the results and it's now 10;

3- finally when i'm using group of orwhere() to do a search in these 10 results, i'm getting results between 0 - 1000 ! as if i didn't do the first two steps !


     $query = Records::where('buyer_id' , $request->id);
 // results is 1000

        if($request->status == 'true'){
            $query->where('status_text','debt');
        }  
// restuls is 100

    // search start here
 
             $query->where('created_at','LIKE','%'.$request->key.'%')
                    ->orwhere('item_name','LIKE','%'.$request->key.'%')
                    ->orwhere('txn_id','LIKE','%'.$request->key.'%')
 
             
 // results between 0 - 1000


        $query=$query->latest()->paginate(15);
 

any help how i could this search to start from the last results between 0 - 10

thanks,

moukbel left a reply on Where('field', Condition)

@snapey

it's another issue

moukbel left a reply on Where('field', Condition)

thanks,

but when this condition run

 $query->orWhere('field',$request->type);

it's cancel the previous one

where('txn' , otherCondition);

and fetch the data as if i did this:

$query = Records::Where('field',$request->type);

is there any way to keep the first condition and modify the results with other conditions using orwhere> i have to use orwhere because i'm doing somekind of search by key:

  ->orwhere('quantity','LIKE','%'.$key.'%')
  ->orwhere('currency','LIKE','%'.$key.'%')
 ->orwhere('order_total','LIKE','%'.$key.'%')

25 Jul
3 weeks ago

moukbel started a new conversation Where('field', Condition)

hi, i have to fetch data where ( field , $request->type ),

but $request->type could be a null , and then i wanna fetch all records

public function getdata(Request $request){

    //   ether $request->type == null then i should fetsh all 
    //   or $request->type == somthing   which is normaly work 

         $fetchData= Records::where('field',$request->type)
                ->orwhere('txn' , otherCondition)
->paginate(5);

    }


moukbel started a new conversation Logout After Session Expire?

hi, maybe it's repeated question,

if I logout after the session expire I got 419 | Page Expired so how to redirect to the login page either as auto redirect or when i post the logout after session expire ,?

thanks,

22 Jul
3 weeks ago

moukbel left a reply on <textarea> Value Binding With Ckeditor

i don't think this is will work !

21 Jul
4 weeks ago

moukbel started a new conversation <textarea> Value Binding With Ckeditor

hi, i have installed CKEditor but i could find way to get the value , the v-model not working !

i have trayed this but i need to click submit two times to get the updated text

<form  @submit.prevent="submit" method='POST' enctype="multipart/form-data">

<textarea id="article-ckeditor"  v-model="about" ref="about"  name="about" class="form-control" placeholder="about" required> </textarea>
<form>     

 methods:{
 
            
            submit(){

               console.log(this.$refs.about.value)

            
            },

moukbel started a new conversation How To Make Menu Active In Slidebar Menu

hi,

i have to use this method in laravel to set current page as active in menu

<li class="nav-item">
                  <a href="/stocks" class="nav-link {{ request()->is('stocks') ? 'active' : '' }}">
                      <p>Stocks </p>
                  </a>
  </li>

Any idea how to do the same thing in Vue Component Menu, without using ?

thanks

17 Jul
1 month ago

moukbel started a new conversation <RouterLink> Cannot Read Property 'resolve'

hi, I'm trying to use to set the correct menu as active when I click it, and I'm getting this error, anyone knows what it's mean?


Error in render: "TypeError: Cannot read property 'resolve' of undefined"

found in

---> <RouterLink>

app,js

import VueRouter from 'vue-router';
Vue.use(VueRouter);

slidebarMenu.js

<nav id="sidebar"  >
    <ul class="list-unstyled components" >
        <li >        
            <router-link to="/cpanel/orders">Orders</router-link>
        <li >
             <router-link to="/cpanel/products"></router-link>
        </li>
   </ul>
</nav>

thanks

16 Jul
1 month ago

moukbel left a reply on Asset() Work With Localhost , Not With Domain.local

Yes, inside the icons directory there is also a file calledicons.svg

moukbel left a reply on Asset() Work With Localhost , Not With Domain.local

@tray2

no, it was icons, if I rename the directory to icons and edit the asset link to src="{{ asset('/icons/1.png') }} i will still get the error

moukbel left a reply on Asset() Work With Localhost , Not With Domain.local

i dont' know why but when i changed the name of the folder from icons to icon it workd

moukbel left a reply on Asset() Work With Localhost , Not With Domain.local

@snapey

yeah it's give 404 , but it's work well and show the picture if i access the project like this

http://localhost/laravel/myproject/public/home
15 Jul
1 month ago

moukbel left a reply on Asset() Work With Localhost , Not With Domain.local

@cronix

sure I have done that

<VirtualHost *:80>
    
    ServerName myproject.local
    ServerAlias myproject.local
    DocumentRoot "C:/wamp64/www/laravel/myproject/public"
    <Directory  "C:/wamp64/www/laravel/myproject/public">
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

moukbel left a reply on Asset() Work With Localhost , Not With Domain.local

APP_URL=http://localhost i have changed to

myproject.local

but still not working

moukbel started a new conversation Asset() Work With Localhost , Not With Domain.local

hi, I add a virtual host to my project myproject.local

the asset() doesn't work

  <img src="{{ asset('/icons/1.png') }}" alt="">

``GET http://myproject.local/icons/1.png 404 (Not Found)``

but seem to work well if I access it like this:

http://localhost/laravel/myproject/public/home

any idea ??

14 Jul
1 month ago

moukbel started a new conversation Changing Variables.scss Not Working !

hi, i start a new project and Im trying to change some variables, what seems is nothing working

$body-bg: red;

i have sure install node_mudules, npm run watch.

app.scss

// Fonts
@import url('https://fonts.googleapis.com/css?family=Nunito');

// Bootstrap
@import '~bootstrap/scss/bootstrap';

// Variables
@import 'variables';

webpack.mix

mix.js('resources/js/app.js', 'public/js')
    .sass('resources/sass/app.scss', 'public/css');

also i got error image not found when i try to load any image inside public/icons

 <img src="{{ asset('/icons/1.png') }}">
13 Jul
1 month ago

moukbel left a reply on Many Virtual Host In Localhost/!! ?

haha sorry, when I reclick the best answer button it doesn't cancel the best answer

moukbel left a reply on Many Virtual Host In Localhost/!! ?

i'm using window system

12 Jul
1 month ago

moukbel left a reply on Many Virtual Host In Localhost/!! ?

service worker only work with https or localhost

moukbel started a new conversation Many Virtual Host In Localhost/!! ?

hi, I wanna set up a all my virtual host on localhost in this way:

localhost/project 1 
localhost/project 2
locahost/...

and the reason for that, i have to test service worker in these project so could not use host name like this:

project1.local
project2.dev
...

any help

15 Jun
2 months ago

moukbel left a reply on Check If $_SERVER['HTTP_REFERER'] Is Empty

@KISIARA - thanks, Kisiara, it's work in both way

moukbel started a new conversation Check If $_SERVER['HTTP_REFERER'] Is Empty

hi, i wanna check from where pages are redirected to my page so i could add the link the back button

i'm using in my controller :

$_SERVER['HTTP_REFERER']

it's work fine but I got an error when someone tries to access my page directly

ErrorException
Undefined index: HTTP_REFERER

I have tried these methods but still nothing work :

   try{
            $location= $_SERVER['HTTP_REFERER'] ;
           
        }
        catch(Exception $exception){
            header('Location: http://www.google.com/');
            exit;
        };

if($_SERVER['HTTP_REFERER'] == null || $_SERVER['HTTP_REFERER'] == ""){
            header('Location: http://www.google.com/');
            exit;
        }else{
            $location= $_SERVER['HTTP_REFERER'] ;  
        }
06 Jun
2 months ago

moukbel left a reply on Can I Make This API More Secure ?

@FTIERSCH - ok thanks, should i make the page as php and insert {!! csrf_field() !!} inside the form?

moukbel left a reply on Can I Make This API More Secure ?

@FTIERSCH - cause i wanna hash the form data with a $secret key , than in the API.php i rehash the received input with same key and compare the two. but it's not correct cause anyone can send the data to '/encode' and received as hashed

05 Jun
2 months ago

moukbel started a new conversation Can I Make This API More Secure ?

Hi,

1 - the User will Fill the forms to buy Something . 2 - encode the form data and send it to API. 3- API will check/release the product .

form:

<form method="POST" action="https://..API" @submit="encodeForm"  >  
<input type="hidden" name="QUANTITY" :value="q">
<input type="hidden" name="CURRENCY" :value="currency">  
<input type="hidden" name="EMAIL" :value="match">  

<input type="hidden" name="m_sign" :value="m_sign">  
...
..
<button type=submit> buy </submit>
</form>

Vue method

encodeForm(){

event.preventDefault(); 
axios.get('/encode', {
     params: {
        currency: usd,
        quantity:2,
    id:1
    ..
    .
     }
     .then(function (response) {
    this.m_sign= response.data;
    e.target.submit();  
}

}

encode.php

encode(Request $request){
$secret='123';
 $arHash = array(
                $id,
                $currency,
                $quantity,
                $m_curr,
                $m_desc
             );

    $m_key = md5($secret);

            $arHash[] = $m_key;
             
             $sign = strtoupper(hash('sha256', implode(':', $arHash)));

             return     $sign ;
}

API.php:

class API extends Controller
{
     
    public function API (Request $request){

    $secret='123';

     // Rejecting queries from IP addresses not belonging to orgingal website
       if (!in_array($_SERVER['REMOTE_ADDR'], array('123.123.12.1'))) return;


    // HMAC Signature check at this point using $secret key
    arHash = array(
        $_POST['1'],
        $_POST[2'],
    ...
    )
    $arHash[] = $secret;
    $sign_hash = strtoupper(hash('sha256', implode(':', $arHash)));
     if ($_POST['m_sign'] == $sign_hash)
        {

    }

    // Check the original price/currency to make sure the buyer didn't change it. 

    //release the product

}
}


shoud i use laravel passport for this

01 Jun
2 months ago

moukbel left a reply on How I Can Write This In Better Way?

@TRAY2 - can I do many user guards using one user's table?

moukbel left a reply on How I Can Write This In Better Way?

@JOHNBRAUN - thanks, i'm getting this ErrorException

htmlspecialchars() expects parameter 1 to be string

moukbel started a new conversation How I Can Write This In Better Way?

public function index()
    {
        $allUsers=array();

        $admin = Admin::all();
        $reseller = Reseller::all();
        $accounting = Accounting::all();

        array_push($allUsers,$admin, $reseller, $accounting);
      
        //$post = Post::orderBy('id','desc')->paginate(5);
        return view('pages.users')->with('allUsers', $allUsers);
    }
<users getallusers='{{!! json_encode($allUsers) !!}}' > </users>

moukbel left a reply on Displaying Message After Successful Registration

@SNAPEY - if i treat the users model as normal model , are they will stay work as a provider for the guard ?

31 May
2 months ago

moukbel left a reply on Displaying Message After Successful Registration

@SNAPEY - thanks snapey,

 don't do this because you will be logged in as the new user and not the admin user.

yes i'm registering other users (admins, writers, users) , any more informaion about the registration flow ?

and where should i use User::create() or writers::create()?

moukbel started a new conversation Displaying Message After Successful Registration

in RegisterController.phpI have used

protected function redirectTo()
    {
       
         return redirect('/users')->with('success','User has Added');   

    }

and I'm getting this message

ErrorException
Header may not contain more than a single header, new line detected

when i use return ' users/' it work fine

moukbel left a reply on Load Multi Table Data

@JLRDW - thanks for helping

moukbel left a reply on Load Multi Table Data

@JLRDW - not 3 databases, it's 3 tables, My mistake

moukbel left a reply on Load Multi Table Data

@TRAY2 - i wanna build guard for every user type with different Features, So to my understanding i need to build model for every user

moukbel started a new conversation Load Multi Table Data

hi, I'm doing a Multiple Users Logging In system, there are 3 table for users type ( Admins, Users, writers )

the admin should see all the registered users, so how i could load all user from the the 3 database , should i call them Separated or there is a way to connect them and make one call ?

thanks

22 May
2 months ago

moukbel started a new conversation Build Page With Java-script Link

hi, I want to build a single webpage using js/HTML , and make people load this page in there website using a javascript link like this:

<script src="https://.www.web.com/webpage.js"></script>

any idea how I can do this?

05 May
3 months ago

moukbel left a reply on How Can I Rename Column In Database? Can I Do That Manually?

1- delete the old table from db 2- then delete the releated row from the migration table 3 - remigrate

moukbel left a reply on Changing DB_PASSWORD

@TRAY2 - thanks tray2, yes i have changed the password in the mysql first

moukbel left a reply on Changing DB_PASSWORD

@PUNKSOLID - thanks punkolid , i'm doing this artisan as you see in the code

04 May
3 months ago

moukbel started a new conversation Help With Firebase Php Notification;

hi, i'm trying to send / recive notification using firebase

i know how to upload cloude messging but how i can recive the notificaion after that ?

firebase controller.php

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Kreait\Firebase;
use Kreait\Firebase\Factory;
use Kreait\Firebase\ServiceAccount;
use Kreait\Firebase\Database;
use Kreait\Firebase\Messaging\Message;
use Kreait\Firebase\Messaging\MessageToTopic;
use Kreait\Firebase\Messaging\Notification;
use Kreait\Firebase\Messaging\CloudMessage;

class FirebaseController extends Controller
{
    public function index(){
        $serviceAccount = ServiceAccount::fromJsonFile(__DIR__.'asdasd-firebase-adminsdk-6rxwm-58430d1f78.json');
        $firebase         = (new Factory)
                        ->withServiceAccount($serviceAccount)
                        ->withDatabaseUri('https://asdasd-e12f2.firebaseio.com')
                        ->create();
        $database       = $firebase->getDatabase();
        $newPost          = $database
                            ->getReference('blog/posts')
                            ->push(['title' => 'Post title','body' => 'This should probably be longer.']);
        echo"<pre>";
        
        
        print_r($newPost->getvalue());
        
 
        
        $topic = 'a-topic';
        
        $message = CloudMessage::withTarget('topic', $topic);
        $message = CloudMessage::fromArray([
             'topic' => $topic
       
        ]);
        
        
        $registrationTokens = [
                $topic
        ];
        
        

        $messaging = $firebase->getMessaging();
        
        $messaging->subscribeToTopic($topic, $registrationTokens);
        
        $messaging->send($message);
        
        
        
        $title = 'My Notification Title';
        $body = 'My Notification Body';
        
        $notification = Notification::fromArray([
            'title' => $title,
            'body' => $body
        ]);
        
        $notification = Notification::create($title, $body);
       
       
       
       $data = [
            'first_key' => 'First Value',
            'second_key' => 'Second Value',
        ];
        $message = $message->withNotification($notification);
        
        $message = $message->withData($data);         
                
        
    }
} 
 

moukbel started a new conversation Changing DB_PASSWORD

hi, when I'm changing DB_PASSWORD via. env I'm getting access denied for this user i'm using these artisan command using route but still got the same problem

Route::get('/clear-cache', function() {
   
    $exitCode = Artisan::call('cache:clear');
    $exitCode = Artisan::call('config:clear');
    $exitCode = Artisan::call('config:cache');
 
});

what else should i update to allow access db using the new user

thanks

02 May
3 months ago

moukbel left a reply on Array OrderBy Work Only For First Letter!

@FTIERSCH - thanks it's work now, but there is little problem, when i convert the value to an integer i need two make the number with to decimal like this 0.00

when i use : parseInt() => it's return a integer without decimal, parseFloat( ).toFixed(2) => it's return a string with 2 decimal , not an integer Number() => it's return a integer with valued decimal like 00.1

any idea how to return Integer with decimal even the number has no value like 0.00?

moukbel started a new conversation Array OrderBy Work Only For First Letter!

hi, I'm trying to make a sorting table, everything works well except when the number gets higher than 9. the orderd will be somthing like this :

1
1
12
17
5
6
7
8
85
9

instead of 

1
1
5
6
7
8
9
12
16
85

computed: {
         
            orderedProducts: function () {
                const vm = this;
                return _.orderBy( vm.filterby , [vm.sortKey], ['asc'])
            },
}